如何在Azure Arm模板中使用粘性登台插槽

编程入门 行业动态 更新时间:2024-10-06 10:30:20
本文介绍了如何在Azure Arm模板中使用粘性登台插槽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

How can you deploy sticky settings to a production app slot in azure web apps using ARM templates without overwriting the existing app settings?

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

I'm using Azure ARM templates to deploy my environment and code releases. The environment has both Staging and Production slots. Part of the deployment is deploying AppSettings. We deploy to Staging, test, then swap to prod.

直到现在,当我需要将粘性AppSetting部署到产品中时,该系统一直运行良好.通常,部署是增量部署,但是当我尝试为生产创建粘性设置时,所有其他设置都会被清除.

This system has been working well until now, when I need to deploy a sticky AppSetting to prod. Normally, the deployments are incremental, but when I try to create a sticky setting for production, all of the other settings get wiped out.

我正在使用slotconfignames在产品插槽中指定粘性变量

I'm using slotconfignames to specify the sticky variables in the prod slot

{ "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和stage appsettings创建单独的资源-当我这样做时,prod slot appsettings被完全覆盖.这在某种程度上是可以预期的:

I've tried creating separate resources for the prod appsettings and the stage appsettings - when I do, the prod slot appsettings are completely overwritten. This is somewhat expected:

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

如果我在舞台插槽设置中进行了相同的设置,则不会在产品上进行设置,但会在舞台插槽上设置为粘性.

If I make those same settings as part of the stage slot settings, then they aren't set on prod, but are set as sticky on the stage slot.

{ "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部署到产品中时.通常,部署是增量部署,但是当我尝试为生产创建粘性设置时,所有其他设置都会被清除.

when I need to deploy a sticky AppSetting to prod. Normally, the deployments are incremental, but when I try to create a sticky setting for production, all of the other settings get wiped out.

根据我的测试,如您所说,ARM模板中未定义的App设置将被清除. 指定粘性插槽设置.

Based on my test, as you said, the App settings that are not defined in your ARM template will be wiped out. Please make sure you include all App settings in your ARM template when you specify sticky slot settings.

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

更多推荐

如何在Azure Arm模板中使用粘性登台插槽

本文发布于:2023-11-28 06:21:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641274.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:插槽   粘性   模板   如何在   Arm

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!