java function runtime discrepancy causing random exception around filepath parsing
az functions version 2
java
Question
so my azure function will sometimes run without issue, usually as long as it stays up and running it will continue to work on each invocation, then if idle and restarts on next invocation, the 'filepath cannot be resolved' issue often reappears. this is the standard backslash \ forward slash / issue between different runtimes, i.e. windows vs linux. but i can run this function locally, with the / as the file separator, and it runs everytime both on linux and windows env's. but there is something about the azure function java runtime that cannot parse the filepath correctly sometimes. I notice it does convert the / to a \ in the filepath but then cannot resolve it.
e.g. this morning on first invocation of the function, it failed with the issue. I restarted the function, now its working.
if i change the app settings in the azure console to run on 64 bit system, it works (without an explicit restart), then if i change it back to 32bit it still works.
there must be some other setting or runtime parameter that differs that results in inability to parse filepath.
I also tried using the File.Separator instead of the / in the function, but it just parses it the same and replaces it with the \ at runtime and still can throw the exception
Looping in @amamounelsayed
@gilmojoa I also see the thread that was started here https://social.msdn.microsoft.com/Forums/en-US/6586d822-eeea-4fc8-ba28-87fd65882702/deployed-azure-java-function-filepath-cannot-be-resolved-randomly-seems-to-be-dependent-on?forum=AzureFunctions
Were you able to get this resolved?
Hi, No we did not resolve this issue. As a workaround we Switched to reading the files from inside the deployed jar, specifying jar classpath instead. Would be good to know if someone has an update on resolution for this Joanne
From: Yogesh Jagadeesan [email protected] Sent: 14 October 2019 20:20:42 To: Azure/azure-functions-host [email protected] Cc: Gilmore, Joanne [email protected]; Mention [email protected] Subject: Re: [Azure/azure-functions-host] java function runtime discrepancy causing random exception around filepath parsing (#4512)
Looping in @amamounelsayedhttps://github.com/amamounelsayed
@gilmojoahttps://github.com/gilmojoa I also see the thread that was started here https://social.msdn.microsoft.com/Forums/en-US/6586d822-eeea-4fc8-ba28-87fd65882702/deployed-azure-java-function-filepath-cannot-be-resolved-randomly-seems-to-be-dependent-on?forum=AzureFunctions
Were you able to get this resolved?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Azure/azure-functions-host/issues/4512?email_source=notifications&email_token=AEJSYPC3UJ5WTZECSOUCPH3QOTBAVA5CNFSM4HRFY3K2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBGEMHQ#issuecomment-541869598, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEJSYPBXWNZY5RI44C6FEWLQOTBAVANCNFSM4HRFY3KQ.
@amamounelsayed I'm moving this to the Java Worker repo for tracking, but let us know if there's anything we need to track on the host.
@fabiocav Sounds good, We will triage it and will let you know if we need anything from host side. Thank you!
@gilmojoa Can you please share code example?
hi, unable to provide code sample at the moment, its possible this issue has been resolved as i did try implementing the sandbox java example with the addition of reading file from filepath, but unable to reproduce issue. However please see following observations which might help in explaining issue origin and whether or not this was a bug/has been resolved. would be great to have some insight around deployment path based on these observations?
The issue with the file path that I have discovered is that typically all code would be run from the D:\home\site\wwwroot directory from my assumption but maybe not always. When running an app with a runtime java and using a consumption plan the following occurs:
- When 32 bit, code is run from D:\local\Temp\functions\standby\wwwroot
- When 64 bit, code is run from D:\home\site\wwwroot\
- Change back to 32 bit, code is still now runs from D:\home\site\wwwroot\
The code runs but within the code we try to fetch some contents from an external file stored in D:\home\site\wwwroot\ directory but we don’t specify the absolute file path but a relative path and this is why it fails when run from the D:\local\Temp\functions\standby\wwwroot directory.