如何在Azure Arm模板中使用粘性登台插槽 [英] How to use sticky staging slots in Azure Arm Templates

查看:58
本文介绍了如何在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模板中使用粘性登台插槽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆