Azure / azure-functions-on-container-apps

Docs , samples and issues for Azure Functions on Azure Container Apps
MIT License
74 stars 18 forks source link

Azure Function Host ID isn't persisted across new revisions or restarts #67

Open mr-panucci opened 4 months ago

mr-panucci commented 4 months ago

Which trigger/binding are you using? SQL Trigger, but I believe this issue is relevant for any trigger.

Which language are you using? C#

Provide resource details N/A

Expected behavior As per the documentation and the behaviour of Function Apps hosted outside of Azure Container Apps, I'd expect the "Host ID to uniquely identify a particular Function App". If the default behaviour is intended to not work this way for Azure Container Apps hosting, I'd expect the Functions on ACA documentation to detail this and how to configure the app to resolve it.

Actual behavior The Host ID changes when the Azure Container App has a new revision or even simply restarted. I discovered this due to the SQL trigger continuously obtaining a new UserFunctionID which is based off of the Host ID. This causes the Function to replay historical changes for the SQL table.

To Reproduce Steps to reproduce the behavior:

  1. Containerise a Function App
  2. Deploy the App
  3. Note the Host ID
  4. Create a new revision
  5. Note the changed Host ID

Screenshots N/A

Logs N/A

Additional context Containerised Function is based on mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0 image.

mukundnigam commented 4 months ago

Can you share the resource ID for this? Is it deployed as "FunctionsApp on ACA" or using the functions image to deploy in ContainerApps ?

mr-panucci commented 4 months ago

I'm not sure what the difference is between the two you mention, but I used this tutorial as my starting point.

I'm not able to share the resource ID with you publicly unfortunately. I've resolved the issue by setting the AzureFunctionsWebHost__hostid environment variable to something static. Whilst I've managed to get around it, the default behaviour of automatically generating this ID doesn't seem to be as expected and there's no mention of this limitation in the documentation as best as I can see.

mukundnigam commented 4 months ago

@mr-panucci . Thanks for providing the link to the tutorial. Can you open a support ticket with Microsoft so that you can provide the details about your resources in a secure way. It will help us to look into the issue more appropriately. Also, please add the details about :- a. Where do you see the hostid (specific logs, etc) b. How are you triggering the new revision.