ARM 模板:如何确保 Web 应用程序插槽不会部署 Web 应用程序设置?

ARM Template: How can i ensure Web App slots do not get the Web App Settings deployed over?

我为 Azure 上的暂存和生产环境准备了完整的 ARM 模板。它通过 Azure DevOps 发布。

但是,我注意到我在我的 ARM 中为 Web 应用程序应用的 Web 应用程序设置,它也复制到 Web 应用程序插槽。我知道这可以在 Azure 上手动勾选,但有没有办法在 ARM 模板上完成?我查看了 Microsoft 网站,但没有看到任何帮助,想知道这是否是一个手动任务?

{
        "type": "Microsoft.Web/sites/config",
        "apiVersion": "2019-08-01",
        "location": "[resourceGroup().location]",
        "name": "[concat(parameters('webAppName'), '/appsettings')]",
        "dependsOn": [
            "[parameters('webAppName')]",
            "[concat(parameters('sqlDatabase'), 'constr')]"
        ],
        "properties": {
            "APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(resourceId('Microsoft.Insights/components', parameters('appInsights')), '2014-04-01').InstrumentationKey]",
            "ApplicationInsightsAgent_EXTENSION_VERSION": "~2",
            "DiagnosticServices_EXTENSION_VERSION": "~3",
}

这就是我的应用程序设置代码的样子(还有更多应用程序设置我没必要全部复制)

下面是我的 Web App Slots ARM 代码

{
        "apiVersion": "2019-08-01",
        "type": "Microsoft.Web/sites/slots",
        "name": "[concat(parameters('webAppName'), '/', parameters('slots')[copyIndex()])]",
        "kind": "app",
        "location": "[resourceGroup().location]",
        "copy": {
            "name": "WebAppSlots",
            "count": "[length(parameters('slots'))]"
        },
        "properties": {
            "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('planName'))]"
        },
        "dependsOn": [
            "[parameters('webAppName')]",
            "[concat(parameters('sqlDatabase'), 'constr')]"
        ]
    },

我非常感谢任何关于此事的见解。

谢谢:)

使用 ARM 模板的插槽设置是一个巨大的痛苦。在 ARM 模板中没有一种方法可以在不实际复制插槽定义中的属性部分的情况下复制设置。

由于您使用 Azure DevOps 进行部署,因此您可以使用更多选项。在我的脑海中,这些包括:

  • 使用 Azure App Service Settings Task 将您的 Web 应用程序和插槽设置设置为管道的一部分。
  • 我在使用 Azure App Configuration Service 时非常幸运。这将需要您编写一些代码,但我喜欢配置历史记录跟踪、比较以及无需回收 Web 应用程序即可热交换设置的功能。
  • 我还刚刚执行了 Powershell 脚本作为我的部署管道的一部分来设置 Azure Web 应用程序和插槽设置。有了上述方法的可用性,我会说这是一个遥远的三分之一。但为了完整起见,我想将其包括在内。