Monday, September 9, 2013

Unexpected Process.Start Behaviour in Azure WorkerRole

Unexpected Process.Start Behaviour in Azure WorkerRole

I'm having some strange behaviour.
Basically, my code runs fine on my local machine and when I login with a
remote desktop to the service, I can run the exe no problem from the
command line with the exact same arguments I give it in C#. It works
perfectly.
What I'm wondering, is if there are any restrictions or permissions that
prevent the exe from being run within an Azure WorkerRole?
The exe does not redirect any stdout or stderr so I can't read any output
when there's an error. This also occurs on my local.
The exe is set to copy to the application's build directory on azure. The
exe exists at the path specified (I've tried File.Exists there and for
where the pdf is, just to make sure)
I've tried setting startInfo.CreateNoWindow to true to see if I can view
the process running within remote desktop, but I can't. I assume the
WorkerRole and remote desktop are different users on the machine.
Here's my code:
LocalResource tempStorage = RoleEnvironment.GetLocalResource("TempStorage");
string tempDir = tempStorage.RootPath;
string tempName = Guid.NewGuid().ToString();
string tempFile = Path.Combine(tempDir, tempName + ".pdf");
string saveFile = tempName + ".html";
string exeDir =
Path.Combine(Environment.GetEnvironmentVariable("RoleRoot") + @"\",
@"approot\Resources\");
File.WriteAllBytes(tempFile, fileBytes);
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = Path.Combine(exeDir, "pdf2htmlEX.exe");
startInfo.UseShellExecute = false;
startInfo.WorkingDirectory = exeDir;
//startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = String.Format("--zoom 1.5 --dest-dir \"{0}\" \"{1}\"
\"{2}\"", tempDir, tempFile, saveFile);
startInfo.CreateNoWindow = true;
using (Process proc = Process.Start(startInfo))
{
proc.WaitForExit(30000);
}
// saveFile does not exist here or any time after the process exists
Using this project's exe. It's great:
https://github.com/coolwanglu/pdf2htmlEX

No comments:

Post a Comment