Skip to content

Instantly share code, notes, and snippets.

@crowcoder
Created December 22, 2015 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crowcoder/613104a403cec7f503fc to your computer and use it in GitHub Desktop.
Save crowcoder/613104a403cec7f503fc to your computer and use it in GitHub Desktop.
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