2
votes

I am trying to create web app slots through ARM template.

I was able to create those but it looks like the default behavior is to create the them as a copy of the current web app state. This result in my slot inheriting app settings, connection strings, virtual directories, ....

Here a reproduction sample which demonstrate the behavior https://github.com/ggirard07/ARMSlotWebConfig.

I want my slot clean and fresh instead, which is the azure portal default behavior. The portal is able to allow a user to select the behavior by specifying the "configSource": "", value it posts when creating the slot.

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

2
If the portal has the behaviour that you want, would it be an option to mock it up there and then view the automation script generated?huysmania
The generated template is not really wise, it is a full dump of all the slot settings. If I go that way, it means I'll have to duplicate every single website configuration value in each of my slot. This will be a nightmare to maintain. I am looking for a clever way to do it, as the portal is doing.GGirard

2 Answers

3
votes

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.

0
votes

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

      ]

    }