0
votes

I have fully working ARM Template for our Staging and Prod environments on Azure. It is released via Azure DevOps.

However, i noticed that the Web App settings i have applied in my ARM for the Web App, it replicates over to the Web App Slots also. I know this can be manually ticked off on Azure, but is there a way to do it on the ARM template? I have looked at Microsoft Website but not seeing any help, and wondering if it is a manual task?

{
        "type": "Microsoft.Web/sites/config",
        "apiVersion": "2019-08-01",
        "location": "[resourceGroup().location]",
        "name": "[concat(parameters('webAppName'), '/appsettings')]",
        "dependsOn": [
            "[parameters('webAppName')]",
            "[concat(parameters('sqlDatabase'), 'constr')]"
        ],
        "properties": {
            "APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(resourceId('Microsoft.Insights/components', parameters('appInsights')), '2014-04-01').InstrumentationKey]",
            "ApplicationInsightsAgent_EXTENSION_VERSION": "~2",
            "DiagnosticServices_EXTENSION_VERSION": "~3",
}

This is what my App Settings code looks like (there are more app settings no point me copying it all)

Below is my Web App Slots ARM code

{
        "apiVersion": "2019-08-01",
        "type": "Microsoft.Web/sites/slots",
        "name": "[concat(parameters('webAppName'), '/', parameters('slots')[copyIndex()])]",
        "kind": "app",
        "location": "[resourceGroup().location]",
        "copy": {
            "name": "WebAppSlots",
            "count": "[length(parameters('slots'))]"
        },
        "properties": {
            "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('planName'))]"
        },
        "dependsOn": [
            "[parameters('webAppName')]",
            "[concat(parameters('sqlDatabase'), 'constr')]"
        ]
    },

I would really appreciate any insight on this matter possible.

Thank you :)

1

1 Answers

1
votes

Slot settings using ARM templates are a giant pain. There isn't a way within an ARM template to duplicate settings without actually duplicating your properties section in the slot definition.

There are more options available to you since you're using Azure DevOps for deployment. Off the top of my head, these include:

  • Using the Azure App Service Settings Task to set your Web App and Slot settings as part of your pipeline.
  • I've had a lot of luck using the Azure App Configuration Service. This will require a little code on your end, but I love the configuration history tracking, comparison, and the ability to hotswap settings without having to recycle your Web App.
  • I've also just executed Powershell scripts as part of my deployment pipeline to set Azure Web App and Slot settings. With the availability of the aforementioned methods, I'd say this is a distant third. But I wanted to include it for completeness.