Azure / azure-functions-durable-extension

Durable Task Framework extension for Azure Functions
MIT License
713 stars 268 forks source link

Something weird is happening to the location of the function #2823

Closed well0549 closed 4 months ago

well0549 commented 4 months ago

Description

I have a XmlUrlResolver that i use in my durable functions. This fileresolver will try to resolve a xsd to a xsd file stored in the function itself. (Copy to Output directory = true, so it's sitting in wwwroot/subfolder/schemafolder/schemaname)

Now in a .net 6.0 function (not isolated) I would get something like

C:\Program Files (x86)\SiteExtensions\Functions\4.31.0\32bit\Order.xsd

I would split this string on 32bit or 64 bit so i would get the filename. Then i could prepend

C:/home/site/wwwroot/subfolder/schemafolder/ to get the full path of the schema. C:/home/site/wwwroot/subfolder/schemafolder/order.xsd

But in a 8.0 isolated function, this works most of the time. But sometimes I Get a completely different path. The path then looks like:

C:/local/Temp/functions/standby/wwwroot/Persons.xsd

Expected behavior

I would expect the function to report the same base folder every time, so I expect something like:

C:\Program Files (x86)\SiteExtensions\Functions\\32bit\ C:\Program Files (x86)\SiteExtensions\Functions\\64bit\

but not: C:/local/Temp/functions/standby/wwwroot

Actual behavior

The behaviour of the function runtime is not consistent. I think the folder is trying to load the xsd from folder the function is running in. I expect that to be a constant. The same for running functions and standby functions.

Relevant source code snippets

no real code snippet. The XmlResolver uses the:

public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)

And the absoluteuri differs sometimes.

Known workarounds

I could check for this value. and adapt for it.

App Details

Durable functions .Net 8.0 Isolated

(Runs ok in .net 6.0 not isolated)

davidmrdavid commented 4 months ago

Hi @well0549 - this is interesting. In general, Durable Functions does not really control filesystem locations or anything like that, so it's likely we'll have to route you to another group. What OS and what SKU (consumption, dedicated, elastic premium) is your app on? That would help me determine who can help.

well0549 commented 4 months ago

windows consumption plan c# .net8.0 Isolated

davidmrdavid commented 4 months ago

@well0549 - from what I'm told internally, if your app is coming from a placeholder pool (an optimization technique we use to reduce coldstarts), it's possible the path may change, as you experience.

As a best practice, I think it's ideal not to make any hard assumptions about the filesystem in a serverless environment, so I think what you describe in your 'known workaround' is probably the right thing to do in either case.

well0549 commented 4 months ago

I have the code in place for now. But the validator will load from current executing folder, and ther could be subpath's underneath the xsd folder. Is there a clean way that will give the current executing folder in a function app ?. Then i can use that instead of what i have now.

well0549 commented 4 months ago

closed