I have an ASP.NET MVC 5 app where I need to invoke wkhtml2pdf.exe in my Azure website using Process.Start
. Locally everthing works fine. But it seems my app stuck at Process.Start
line. Is starting a process is supported on Azure?

- 32,612
- 68
- 179
- 322
2 Answers
ramiramilu's answer is actually not correct. You can run any exe you want (check this for example). The problem you are hitting is not in running an exe, it's something specific to wkhtml2pdf.exe
itself. That exe uses a bunch of GDI+
calls on Windows for rendering the PDF and that is what's not allowed in Azure Websites sandbox (the GDI+
calls, not running an exe).
Using a WebJob won't help either because WebJobs run in the same context as the site which means under the same sandbox.
Edit:
There is nothing special to how you would launch an external process on Azure Websites than how you would do it normally with C#. Again the problem you are facing is with wkhtml2pdf.exe
and not with the general concept of launching a process.
Here is a sample that you can try that launches cmd.exe
and reads what is written on stdout
var processStartInfo = new ProcessStartInfo()
{
Arguments = "/c echo \"test\"",
FileName = @"c:\windows\system32\cmd.exe",
RedirectStandardOutput = true,
UseShellExecute = false
};
var process = Process.Start(processStartInfo);
using (var streamReader = new StreamReader(process.StandardOutput.BaseStream))
{
ViewBag.MessageFromExe = streamReader.ReadToEnd();
}
ViewBag.MessageFromExe
will have the value "test"
you can verify that on your view and you can run that just fine in Azure Websites

- 7,125
- 3
- 28
- 40
-
Do you have any running example on ASP.NET website? – Imran Qadir Baksh - Baloch Feb 03 '15 at 19:06
-
Well my point is that using ASP.Net MVC5 application, it is not possible to run Process.Start() in AzureWebsite. – ramiramilu Feb 03 '15 at 19:45
-
Thanks. Hopefully I can use it in ASP.NET(MVC 5) as well Correct? – Imran Qadir Baksh - Baloch Feb 04 '15 at 06:13
-
1[At beginning 2016 Chrome dropped GDI+ in favor of DirectWrite](https://chromium.googlesource.com/chromium/src/+/1acd6b6af8c9ef59fe7227faff4585310e5c2ec8). This caused new wkhtml2pdf.exe to work on Azure Website. – PTwr Oct 13 '16 at 13:38
-
Thanks for this @ahmelsayed. What processes are or are not allowed in an Azure Website/App sandbox? Is there any way to find the exact cause of why an .exe does not execute? I'm guessing this is the same problem: http://stackoverflow.com/questions/41841339/running-exe-on-azure – ajbeaven Mar 11 '17 at 19:59
-
1Microsoft published an article that, to my surprise, incorrectly (?) asserts that you cannot start processes in Azure Websites and that you can in WebJobs and the author got `wkhtml2pdf` to work there : https://msdn.microsoft.com/en-us/magazine/mt707529.aspx - but I think it worked for him because of the coincidental change in WebKit that uses DirectWrite. – Dai May 05 '17 at 22:29
-
Update (12/12/2018) According to the [Azure Sandbox Documentation](https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#unsupported-frameworks) WkHtmlToPdf is now supported, with the limitation that GDI+ is still restricted. Works fine if you only use system installed fonts. – Adam Vincent Dec 12 '18 at 21:26
You can use an alternative way to do PDF generation that will work in Azure WebApps. See this blog.

- 201
- 2
- 3