简体   繁体   English

从 Azure DevOps 进行新的 ARM 部署后删除了 Azure 函数代码

[英]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.我正在运行自定义 ARM 模板,以通过 Azure DevOps 管道为 Azure 功能创建基础结构(动态应用服务计划、存储帐户等)。

I am also deploying my function code via Azure DevOps from a different Github repo in a different Azure DevOps pipeline.我还在不同的 Azure DevOps 管道中通过来自不同 Github 存储库的 Azure DevOps 部署我的函数代码。

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 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).当 ARM 模板运行时,它会替换应用服务的应用设置(也适用于函数)。

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.我没有意识到用于部署函数代码的 Azure Dev Ops 任务实际上是使用这种新的 run from package 部署方法,所以我应该在我的 ARM 模板的应用程序设置部分进行设置。

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.当我在部署代码后第二次运行 ARM 模板时,它正在删除 WEBSITE_RUN_FROM_PACKAGE 设置,因此该函数不知道代码在哪里。

To fix the issue I simply added { "name": "WEBSITE_RUN_FROM_PACKAGE", "value": "1" } to my ARM template!为了解决这个问题,我只是在我的 ARM 模板中添加了 { "name": "WEBSITE_RUN_FROM_PACKAGE", "value": "1" } !

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我想指出 Functions 的 Azure DevOps 任务现在使用从包运行: Azure Functions ARM 模板部署删除函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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