2

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? Commented Apr 25, 2018 at 14:44
  • 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. Commented Apr 25, 2018 at 16:19

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Why looking for complicated stuff when it can be that easy :) ARM templating really needs a comprehensive doc to become a really productive solution... right now it takes more time to find the info about how to author the template than managing the resources by hand or old school powershell script
@GGirard agreed that some things are way harder than they should be to figure out. Hopefully next person who needs it will find this question :)
0

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

      ]

    }

1 Comment

Thanks for confirming you're getting the same behavior. Overriding existing base configuration is what I want to avoid because it will be hard to maintain and will not scale properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.