简体   繁体   中英

Azure Function code deleted after a new ARM deployment from Azure DevOps

I am running a custom ARM template to create the infrastructure (Dynamic App Service plan, Storage account etc.) for an Azure function through an Azure DevOps Pipeline.

I am also deploying my function code via Azure DevOps from a different Github repo in a different Azure DevOps pipeline.

After I've successfully deployed the infrastructure and code if the pipeline for the infrastructure runs again it deletes the code, even if the changes I am making to the infrastructure don't effect the function and I run in Incremental mode.

It turns out the issue was a missing setting.

https://docs.microsoft.com/en-ca/azure/azure-functions/run-functions-from-deployment-package

When an ARM template runs it replaces an the app settings for an app service (for Functions too).

I didn't realize that the Azure Dev Ops task for deploying function code is actually using this new run from package deployment method so I should have had the setting in the app settings portion of my ARM template.

When I ran the ARM template a second time after the code had been deployed it was removing the WEBSITE_RUN_FROM_PACKAGE setting so that the function didn't know where the code was.

To fix the issue I simply added { "name": "WEBSITE_RUN_FROM_PACKAGE", "value": "1" } to my ARM template!

Note this is very similar to this question. I wanted to call out that the Azure DevOps task for Functions now uses Run from Package: Azure Functions ARM Template deploy deletes Functions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM