Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# Azure Functions using System.Diagnostics.Process for Java #837

Closed
chiefmultihat opened this issue Jun 8, 2018 · 6 comments
Closed

C# Azure Functions using System.Diagnostics.Process for Java #837

chiefmultihat opened this issue Jun 8, 2018 · 6 comments
Assignees

Comments

@chiefmultihat
Copy link

chiefmultihat commented Jun 8, 2018

I needed a way for a utility written in Java to run via azure functions. As Java was experimental, I found using the console on my function app, I could find Java runtime binaries. So I used System.Diagnostics.Process and setup a window-less "shell" to execute Java.exe with the command arguments needed to run my uploaded Jar file against data found in my d:\home\site\wwwroot\data... etc folders. This solution has worked for about a year. I wrote a queue trigger that executed a function within a assembly uploaded to azure via VS 2017 Azure Functions SDK.

Recently all the Java binaries have disappeared from my functions' environment and now I'm no longer able to execute java. I don't need a java function, I need to run java in a function. Can/Would this be possible in the future / can I have this back :)

Thanks,
Dave

@paulbatum paulbatum self-assigned this Jun 8, 2018
@paulbatum paulbatum added this to the Active Questions milestone Jun 8, 2018
@paulbatum
Copy link
Member

I've reached out to some of the folks on my team that should know what happened to java.exe. Hopefully I'll have an answer for you sometime next week.

@paulbatum
Copy link
Member

Got an answer quicker than I expected. Apparently there is supposed to be behavior that acquires this on demand.

There are more details here:
https://social.msdn.microsoft.com/Forums/en-US/663d5aa6-7397-4481-8759-9ee3e1817f56/running-java-inside-a-function?forum=AzureFunctions

It seems like this is working for me from within my test function by just doing

var info = new System.Diagnostics.ProcessStartInfo(@"d:\Program Files (x86)\Java\jdk1.7.0_51\bin\java.exe");
var process = System.Diagnostics.Process.Start(info);
process.WaitForExit();

I am curious what access pattern your function is using that could result in this on-demand behavior not working right...

@chiefmultihat
Copy link
Author

I think my issue was just due to the fact I must of hit the roll out of this JIT process and so I saw some issues. Now that I see how it will work, I just need to make sure I choose to use the right JDK version.

@chiefmultihat
Copy link
Author

After a few weeks with working with this, I notice it takes about 45 seconds even up to 90 seconds per function execution to spin up the needed Java resource before running the Jar file in a Diagnostics process.

Is there a way to install a java runtime within a functions bin folder and use that?

@paulbatum
Copy link
Member

Yes I am following up internally about trying to make sure that the version of java used by functions is not acquired lazily as it seems like it can be quite slow (I have not seen it get as slow as you are describing but I can imagine its possible). That is tracked here.

I am not sure if your proposed approach would work because I'm unclear about java.exe's portability. Is running in a dedicated app service plan an option for you? If you do this, the VMs used to run your application should change far less often and should acquire Java much faster.

Hopefully we will make progress on getting the default version of Java restored to being pre-installed on the VM and that would address your issue properly.

@chiefmultihat
Copy link
Author

A dedicated app plan is not an option for me at this time, but I would agree in thinking that would speed up the pre-process time. For now I can keep working with how functions will behave with the JIT behavior. It would be nice if the response could increase (or I re-write the java utility in c# - another time...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants