Created
December 22, 2015 19:43
-
-
Save crowcoder/613104a403cec7f503fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Azure.WebJobs; | |
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.IO; | |
namespace TestWebjob | |
{ | |
public class Functions | |
{ | |
// This function will get triggered/executed when a new message is written | |
// on an Azure Queue called queue. | |
public static void ProcessQueueMessage([QueueTrigger("webjobtestq")] string message, TextWriter log) | |
{ | |
try | |
{ | |
var javaHome = Environment.GetEnvironmentVariable("JAVA_HOME"); | |
ProcessStartInfo psi = new ProcessStartInfo(javaHome + "\\bin\\java", string.Concat(" -jar .\\App_Data\\AzureWebjobJar.jar ", message)) | |
{ | |
CreateNoWindow = true, | |
UseShellExecute = false, | |
RedirectStandardOutput = true | |
}; | |
Process javaProcess = Process.Start(psi); | |
string theOutput = javaProcess.StandardOutput.ReadToEnd(); | |
javaProcess.WaitForExit(); | |
//code to craft email of output omitted | |
} | |
catch (Exception ex) | |
{ | |
//code to craft email of exception omitted | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment