本文介绍了Azure Functions ARM 模板部署删除 Functions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ARM 模板(如下所示)来部署 Azure Function App.我部署它:

I've got an ARM template (included below) to deploy an Azure Function App. I deploy it with:

az group deployment create --resource-group my-group --template-file my-function-app.json

这可行,然后我可以使用 VS Code 插件或 Azure Functions Core Tools 成功部署我的函数.

This works and I can then deploy my functions successfully using the VS Code plugin or Azure Functions Core Tools.

但是,如果我随后重新部署 ARM 模板(例如更新应用程序设置),我将失去我的功能,需要再次重新部署它们.这是预期的行为吗?这不是我在部署时观察到的,例如通过 ARM 模板的 Web 应用程序.在为 Function App 部署 ARM 模板以保留我已部署的功能时,我可以做些什么具体的事情?

However, if I then re-deploy the ARM template (for example to update an application setting) then I lose my functions and need to re-deploy them again. Is this expected behaviour? It's not what I observe when deploying e.g. a Web App via an ARM template. Is there something specific I can do when deploying an ARM template for a Function App to preserve my deployed functions?

my-function-app.json:

my-function-app.json:

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        ...
    },
    "variables": {
        ...
    },
    "resources": [
        {
            "apiVersion": "2015-08-01",
            "type": "Microsoft.Web/sites",
            "name": "[variables('collectorFunctionAppName')]",
            "location": "[parameters('location')]",
            "kind": "functionapp",
            "properties": {
                "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
                "siteConfig": {
                    "appSettings": [
                        {
                            ...
                        }
                    ]
                }
            }
        }
    ],
    "outputs": {}
}

推荐答案

你是否将你的函数部署为一个包?如果是这样,请确保您在模板中设置此设置,否则在重新部署时它将被删除:

Are you deploying your function as a package? If so, make sure you set this setting in your template, since it will be removed when you redeploy otherwise:

{"名称": "WEBSITE_RUN_FROM_PACKAGE",价值":1"}

{ "name": "WEBSITE_RUN_FROM_PACKAGE", "value": "1"}

这篇关于Azure Functions ARM 模板部署删除 Functions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 18:24