2017-07-27 16 views
1

如何在不覆盖现有应用程序设置的情况下使用ARM模板将粘性设置部署到天蓝色Web应用程序中的生产应用程序插槽?如何在Azure布防模板中使用粘性分段插槽

我正在使用Azure ARM模板来部署我的环境和代码版本。该环境具有分段和生产插槽。部署的一部分是部署AppSettings。我们部署到分期,测试,然后交换到产品。

这个系统一直运行良好,直到现在,当我需要部署一个粘性AppSetting prod。通常情况下,部署是渐进式的,但是当我尝试为生产创建粘性设置时,其他所有设置都会被清除。

我使用slotconfignames到指定督促槽粘变量

{ 
     "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" ] 
     } 
    } 

我已经试过了督促的AppSettings和舞台的AppSettings创建单独的资源 - 当我这样做,督促插槽的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" 
    } 
    }, 

回答

1

,当我需要部署一个棘手的AppSetting督促。通常情况下,部署是渐进式的,但是当我尝试为生产创建粘性设置时,其他所有设置都会被清除。

根据我的测试,正如您所说,未在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" ] 
    } 
} 
相关问题