从ARM模板创建Azure Web应用程序插槽,而不复制原始Web应用程序配置

时间:2018-04-25 14:03:56

标签: azure azure-web-sites azure-resource-manager arm-template

我正在尝试通过ARM模板创建Web应用程序插槽。

我能够创建这些但看起来默认行为是将它们创建为当前Web应用程序状态的副本。这导致我的插槽继承了应用程序设置,连接字符串,虚拟目录,....

这是一个演示行为https://github.com/ggirard07/ARMSlotWebConfig的复制样本。

我希望我的插槽清洁干净,这是天蓝色的门户默认行为。门户网站允许用户通过指定创建插槽时发布的"configSource": "",值来选择行为。

无论如何都要在ARM模板中实现相同的目标吗?

2 个答案:

答案 0 :(得分:3)

要阻止从生产应用复制设置,只需在广告位siteConfig中添加空的properties对象即可。 e.g。

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

我发送了PR来说明你的回购。

答案 1 :(得分:0)

  

无论如何都要在ARM模板中实现相同的目标吗?

如果我使用你提到的模板,我也可以在我身边重现它。我也无法通过指定" configSource":""来找到一种选择行为的方法。直接,您可以将feedback提供给Azure团队。

我在部署插槽期间覆盖配置。它在我身边正常工作。您可以使用以下代码替换tempalte中创建的WebApp插槽代码。

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

      ]

    }