[英]How to use sticky staging slots in Azure Arm Templates
如何使用ARM模板將粘性設置部署到azure Web應用程序中的生產應用程序插槽,而不會覆蓋現有的應用程序設置?
我正在使用Azure ARM模板來部署我的環境和代碼版本。 環境具有暫存和生產插槽。 部署部分是部署AppSettings。 我們部署到Staging,測試,然后交換到prod。
這個系統一直運行良好,直到現在,我需要部署一個粘性的AppSetting來生產。 通常,部署是增量的,但是當我嘗試為生產創建粘性設置時,所有其他設置都會被刪除。
我正在使用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"
}
},
當我需要部署一個粘性的AppSetting來生產時。 通常,部署是增量的,但是當我嘗試為生產創建粘性設置時,所有其他設置都會被刪除。
根據我的測試,正如您所說,ARM模板中未定義的應用程序設置將被清除。 指定粘滯槽設置時,請確保在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" ]
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.