如何使用ARM模板将粘性设置部署到azure Web应用程序中的生产应用程序插槽,而不会覆盖现有的应用程序设置?
我正在使用Azure ARM模板来部署我的环境和代码版本。环境具有暂存和生产插槽。部署部分是部署AppSettings。我们部署到Staging,测试,然后交换到prod。
此系统一直运行良好,直到现在,我需要将一个粘性AppSetting部署到prod。通常,部署是增量的,但是当我尝试为生产创建粘性设置时,所有其他设置都会被删除。
我正在使用slotconfignames来指定prod插槽中的粘性变量
{
"apiVersion": "2015-08-01",
"name": "slotconfignames",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('webSiteName'))]"
],
"properties": {
"appSettingNames": [ "WEBSITE_LOCAL_CACHE_OPTION", "WEBSITE_LOCAL_CACHE_SIZEINMB" ]
}
}
我尝试为prod appsettings和舞台appsettings创建单独的资源 - 当我这样做时,prod插槽appsettings被完全覆盖。这有点预期:
{
"apiVersion": "2015-08-01",
"type": "config",
"name": "appsettings",
"dependsOn": [
"[resourceId('Microsoft.Web/sites/', variables('webSiteName'))]"
],
"properties": {
"WEBSITE_LOCAL_CACHE_OPTION": "Always",
"WEBSITE_LOCAL_CACHE_SIZEINMB": "2000"
}
},
如果我将这些设置设置为舞台插槽设置的一部分,则它们不会在prod上设置,但在舞台插槽上设置为粘性。
{
"name": "appsettings",
"type": "config",
"apiVersion": "2015-08-01",
"dependsOn": [
"[variables('stagingSlotName')]",
//"[concat('Microsoft.Web/sites/', variables('webSiteName'))]",
"MSDeploy",
"[concat('Microsoft.Resources/deployments/', 'AppStorage')]"
],
"tags": {
"displayName": "uisettings",
"environment": "[parameters('environmentName')]",
"serviceGroup": "[variables('serviceGroupName')]"
},
"properties": {
...othersettingshere...
"WEBSITE_LOCAL_CACHE_OPTION": "Always",
"WEBSITE_LOCAL_CACHE_SIZEINMB": "2000"
}
},
答案 0 :(得分:1)
当我需要将一个粘性的AppSetting部署到prod时。通常,部署是增量的,但是当我尝试为生产创建粘性设置时,所有其他设置都会被删除。
根据我的测试,正如您所说,ARM模板中未定义的应用程序设置将被清除。请确保在specify sticky slot settings时包含ARM模板中的所有应用设置。
{
"name": "appsettings",
"type": "config",
"apiVersion": "2015-08-01",
"dependsOn": [
"[concat('Microsoft.Web/sites/', variables('webSiteName'))]"
],
"tags": {
"displayName": "uisettings"
},
"properties": {
"AppSettingKey1": "myvalue",
//your other appsettings
"WEBSITE_LOCAL_CACHE_OPTION": "Always",
"WEBSITE_LOCAL_CACHE_SIZEINMB": "2000"
}
},
{
"apiVersion": "2015-08-01",
"name": "slotconfignames",
"type": "config",
"dependsOn": [
"[concat('Microsoft.Web/sites/', variables('webSiteName'))]"
],
"properties": {
"appSettingNames": [ "WEBSITE_LOCAL_CACHE_OPTION", "WEBSITE_LOCAL_CACHE_SIZEINMB" ]
}
}