ARM模板部署中缺少Azure Web App过渡插槽应用程序设置

时间:2019-09-04 09:07:13

标签: azure azure-web-sites azure-resource-manager arm-template

我正在为某些Web应用程序部署设计ARM模板。这些模板设置了一个Web应用程序以及该应用程序的暂存槽。我希望解决的方法是仅将应用程序设置部署到暂存槽。通过这样做,我可以很好地处理回滚,因为应用程序设置将与插槽交换,并且所有旧值都与部署它们的应用程序绑定在一起。但是,成功部署这些ARM模板后,我看到除了website_node_default_version之外,没有其他应用程序设置部署到我的登台插槽中。

以下是ARM模板的摘要,其中显示了一对Web应用程序+临时插槽:

{
        "type": "Microsoft.Web/sites",
        "apiVersion": "2016-08-01",
        "name": "[variables('egressAppName')]",
        "location": "[parameters('location')]",
        "kind": "app",
        "properties": {
            "enabled": true,
            "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
            "clientAffinityEnabled": true
        }
    },
    {
        "type": "Microsoft.Web/sites/slots",
        "apiVersion": "2016-08-01",
        "name": "[concat(variables('egressAppName'),'/','staging')]",
        "location": "[parameters('location')]",
        "dependsOn": [
            "[resourceId('Microsoft.Web/sites', variables('egressAppName'))]"
        ],
        "kind": "app",
        "properties": {
            "enabled": true,
            "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
            "clientAffinityEnabled": true,
            "appSettings": [
                {
                    "name": "APP_INSIGHTS_INSTRUMENTATION_KEY",
                    "value": "[reference(resourceId(variables('rsg') ,'microsoft.insights/components/', variables('ainName')), '2015-05-01').InstrumentationKey]"
                },
                {
                    "name": "ASPNETCORE_ENVIRONMENT",
                    "value": "[parameters('netCoreEnvironment')]"
                },
                {
                    "name": "MONITOR_API_ACCOUNT_RATE_LIMIT",
                    "value": "[parameters('accountRateLimit')]"
                },
                {
                    "name": "MONITOR_API_ACCOUNT_RATE_LIMIT_WINDOW_SECONDS",
                    "value": "[parameters('accountLimitWindow')]"
                },
                {
                    "name": "MONITOR_API_IP_RATE_LIMIT",
                    "value": "[parameters('ipLimit')]"
                },
                {
                    "name": "MONITOR_API_IP_RATE_LIMIT_WINDOW_SECONDS",
                    "value": "[parameters('ipLimitWindow')]"
                },
                {
                    "name": "MONITOR_DATA_EXPLORER_INSTANCE_NAME",
                    "value": "[variables('dataExplorerName')]"
                },
                {
                    "name": "MONITOR_DATA_EXPLORER_REGION",
                    "value": "[parameters('location')]"
                },
                {
                    "name": "MONITOR_DIAG_ACCOUNT_APP_ID",
                    "value": "[parameters('diagAccountAppID')]"
                },
                {
                    "name": "MONITOR_DIAG_ACCOUNT_APP_SECRET_LOCATION",
                    "value": "[parameters('diagAccountAppSecret')]"
                },
                {
                    "name": "MONITOR_EGRESS_APP_TENANT",
                    "value": "[parameters('egressTenantID')]"
                },
                {
                    "name": "MONITOR_KEY_VAULT_APP_ID",
                    "value": "[parameters('keyVaultAppID')]"
                },
                {
                    "name": "MONITOR_KEY_VAULT_APP_SECRET",
                    "value": "[parameters('keyVaultAppSecret')]"
                },
                {
                    "name": "MONITOR_KEY_VAULT_NAME",
                    "value": "[variables('keyVaultName')]"
                },
                {
                    "name": "MONITOR_PGSQL_CONNECTION_STRING",
                    "value": "[parameters('postgresConnectionString')]"
                },
                {
                    "name": "MONITOR_TOKEN_VALIDATION_CLOCK_SKEW_SECONDS",
                    "value": "[parameters('validationClockSkew')]"
                },
                {
                    "name": "WEBSITE_RUN_FROM_PACKAGE",
                    "value": "1"
                }
            ]
        }
    }

我尝试仅删除暂存槽并重新部署,以及删除所有Web应用程序并重新部署,但是没有运气。在这一点上,我只是希望对此有更多的关注,看看我是否错过了任何明显的事情。我正在使用Azure资源组部署任务通过Azure DevOps发布管道部署这些ARM模板。

1 个答案:

答案 0 :(得分:0)

应该在SiteConfig对象中定义appSettings,而不是将Microsoft.Web / sites / slots properties作为模板。要为应用设置创建Microsoft.Web/sites/slots/config资源,可以将JSON添加到模板的资源部分。

此外,您可以看到监视和诊断设置可以交换hereenter image description here