Create Azure web app slot from ARM template without copying original web app configuration

江枫思渺然 提交于 2019-12-04 17:41:18

To prevent the copying of settings from the production app, just add an empty siteConfig object in the slot properties. e.g.

    {
      "apiVersion": "2015-08-01",
      "type": "slots",
      "name": "maintenance",
      "location": "[resourceGroup().location]",
      "dependsOn": [
        "[resourceId('Microsoft.Web/Sites/', variables('webSiteName'))]"
      ],
      "properties": {
        "siteConfig": { }
      }
    }

I sent a PR to illustrate on your repo.

Is there anyway to achieve the same from inside an ARM template?

If I use the template you mentioned, I also can reproduce it on my side. I also can't find a way to select the behavior by specifying the "configSource": "" directly, You could give feedback to Azure team.

I work it out with overriding the config during deploy slot. It works correctly on my side. You could use the following code to replace the creating WebApp slot code in your tempalte.

    {
      "apiVersion": "2015-08-01",
      "name": "maintenance",
      "type": "slots",
      "location": "[resourceGroup().location]",
      "dependsOn": [
        "[resourceId('Microsoft.Web/Sites', variables('webSiteName'))]"
      ],
      "properties": {
      },
      "resources": [
        {
          "apiVersion": "2015-08-01",
          "type": "config",
          "name": "connectionstrings",
          "location": "East US",
          "dependsOn": [
            "[resourceId('Microsoft.Web/Sites/Slots', variables('webSiteName'), 'maintenance')]"
          ],
          "properties": {}
        },
        {
          "apiVersion": "2015-08-01",
          "type": "config",
          "name": "web",
          "tags": {
            "displayName": "Website configuration"
          },
          "dependsOn": [
            "[resourceId('Microsoft.Web/Sites/Slots', variables('webSiteName'),'maintenance')]"
          ],
          "properties": {
            "virtualApplications": [
              {
                "virtualPath": "/",
                "physicalPath": "site\\wwwroot",
                "preloadEnabled": true,
                "virtualDirectories": null
              }
            ]
          }
        }

      ]

    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!