I recently had the need to execute a .jar file from within an Azure WebJob built with C#. I found a few resources that showed how to upload a .zip file, for instance, and have that run a .bat file as a job. Or, how to create a Java web app. But my webjob needed to do more than just run a .jar, and I didn’t have the time to get up to speed on Java and the Azure Storage SDK for Java. As the Google let me down, here I demonstrate the solution.
It turns out there is indeed a JRE available and you can run java.exe. You can either give it a class name that contains a
main entry point, or give it a .jar, exactly a you would do from the command line. The first thing I had to do was determine how to locate java.exe. I made a dump of environment variables and saw that JAVA_HOME was defined.
With this information, all you need to do is craft and execute the proper
Using the Azure Storage Explorer I was easily able to enqueue messages to execute my webjob which is triggered by the queue: