Azure应用服务插槽不同价值的应用设置

时间:2019-05-06 07:51:40

标签: azure azure-web-sites azure-resource-manager azure-webapps

我有一个带插槽的webapp。两者都应具有应用设置名称DISABLE_CRON。 webapp(生产版位)的此设置应设置为false,而版位上的设置应设置为true。我想使用ARM模板来做到这一点。该webapp具有许多appsettings,例如数据库名称,数据库登录用户名和密码等。我希望所有这些设置都在一个变量中,因此我不必一次为webapp写一次,而为插槽写一次。基本上,我只想将广告位上的值更改为true,并保持所有其他设置不变。

"variables": {
    "appName": "[concat(parameters('applicationName'),'-',parameters('environment'),'-app')]",
    "hostingPlanName": "[concat(parameters('applicationName'),'-',parameters('environment'),'-plan')]",
    "dbserverName": "[concat('onlinecampaignsites-',parameters('environment'),'-dbs-01')]",
    "connectionString": "[concat('Database=', parameters('applicationName'), ';Data Source=', concat('onlinecampaignsites-',parameters('environment'),'-dbs-01'),'.mysql.database.azure.com;User Id=',parameters('administratorLogin'),'@',concat('onlinecampaignsites-',parameters('environment'),'-dbs-01'),';Password=',parameters('administratorLoginPassword'))]",
    "appInsightsName": "[concat(parameters('applicationName'),'-',parameters('environment'),'-appIn')]",
    "databaseName": "[parameters('applicationName')]",
    "storageName": "[concat(parameters('applicationName'),parameters('environment'),'stg')]",
    "serverFarmResourceGroup": "[resourceGroup().name]",
    "subscriptionId": "[subscription().subscriptionId]",
    "containerName01": "[concat(parameters('applicationName'),'-',parameters('environment'),'-uploads')]",
    "staging": "staging",
    "appsettings": {
        "DISABLE_CRON": "false",
        "HEJSAN": "Den vann den"
    }
},
"resources": [
    {
        "name": "[variables('appname')]",
        "type": "Microsoft.Web/sites",
        "location": "[resourceGroup().location]",
        "apiVersion": "2018-02-01",
        "dependsOn": [
            "[concat('Microsoft.Web/serverfarms/', variables('hostingPlanName'))]"
        ],
        "properties": {
            "siteConfig": {
                "appSettings": [
                    {
                        "name": "DISABLE_CRON",
                        "value": "true"
                    }
                ]
            },
            "hostNameSslStates":"[concat('{\"name\": \"',parameters('customDomain'),'\", \"sslState\": \"Disabled\", \"virtualIP\": null, \"thumbprint\": null, \"toUpdate\": null,\"hostType\": \"Standard\"}')]",
            "serverFarmId": "[concat('/subscriptions/', variables('subscriptionId'),'/resourcegroups/', variables('serverFarmResourceGroup'), '/providers/Microsoft.Web/serverfarms/', variables('hostingPlanName'))]",
            "hostingEnvironment": "",
            "httpsOnly": true
        },
        "resources": [
            {
                "apiVersion": "2018-02-01",
                "name": "slotconfignames",
                "type": "config",
                "dependsOn": [
                    "[concat('Microsoft.Web/sites/', variables('appName'))]"
                ],
                "properties": {
                    "appSettingNames": [ "DISABLE_CRON" ]
                }
            },
            {
                "apiVersion": "2018-02-01",
                "type": "config",
                "name": "appsettings",
                "dependsOn": [
                    "[concat('Microsoft.Web/sites/', variables('appName'))]"
                ],
                "properties": "[variables('appsettings')]"
            }
        ]
    },
    {
        "apiVersion": "2018-02-01",
        "type": "Microsoft.Web/sites/slots",
        "name": "[concat(variables('appName'), '/', variables('staging'))]",
        "location": "[resourceGroup().location]",
        "dependsOn": [
            "[resourceId('Microsoft.Web/Sites', variables('appName'))]",
            "[concat('Microsoft.Web/serverfarms/', variables('hostingPlanName'))]"
        ],
        "properties": {},
        "resources": [
            {
                "apiVersion": "2018-02-01",
                "type": "config",
                "name": "appsettings",
                "dependsOn": [
                    "[resourceId('Microsoft.Web/sites/slots', variables('appName'), variables('staging'))]"
                ],
                "properties": "[variables('appsettings')]"
            }
        ]
    },

在ARM模板示例中,有两个appsettings。将DISABLE_CRON设置为true无效,我只是想在此示例中进行演示。

0 个答案:

没有答案