App Service (Web App): How to manage Slots App Settings using ARM templates and Azure Pipelines?

Nouvel R 16 Reputation points
2019-11-29T17:19:10.977+00:00

Dear all,

We are currently working on automating deployment of an App Service (Web App) in Azure.

Our goals are:

  • To use slots to do hot deployment
  • To use an Azure DevOps Release pipeline and ARM templates for deploying the App Service resource, including the Staging slot
  • To have another Azure Release pipeline to deploy the binaries of the application to the Staging slot, including App Settings values

Some settings are "deployment slot settings" and some aren't - see https://learn.microsoft.com/en-us/azure/app-service/deploy-staging-slots for explanations.

The problem is, we can't find a way to differentiate the deployment slot settings from those who swap with the slot in ARM template. In ARM template, an App Setting is just a name - value pair, and all App Settings belong to the same App Settings resource type (see https://learn.microsoft.com/en-us/azuretemplates/microsoft.web/2018-02-01/sites).

To the best of my understanding this doesn't allow us to specify slot settings - so what is the solution to do that?

Thanks in advance for your answer.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,163 questions
0 comments No comments
{count} votes

9 answers

Sort by: Most helpful
  1. Nouvel R 16 Reputation points
    2019-12-06T10:59:12.523+00:00

    Nothing to add on this topic?

    So far this is my understanding on programmatically managing sticky App Settings, and it's quite disappointing:

    1. It can't be done with ARM templates
    2. It can't be done with Az PowerShell module
    3. It can be done with Azure PowerShell module, which will be deprecated and is being replaced by Az module mentionned above. The worst part is that Azure Powershell module requires the account used to be administrator or co-administrator of the subscription when Contributor on the Web App should be enough. This poses a security question.

    Microsoft, we need something like Set-AzWebApp -SlotStickyAppSettingNames, and Set-AzWebApp -SlotStickyConnectionStringNames please!

    Slots enable new, safer and more agile deployments, this is great, having sticky App Settings and Connection Strings is needed, so thanks for that, but lack of ability to manage them programmatically (unless done with a solution being deprecated and requiring exagerately high privileges) is a blocker to industrial / large scale use!


  2. greg slack 1 Reputation point Microsoft Employee
    2020-02-07T20:08:59.36+00:00

    Google "slotconfignames". You'll find plenty of info from that. Basically it's a subresource of your app or slot resource.

    0 comments No comments

  3. David Smith 1 Reputation point
    2020-04-26T16:15:50.203+00:00

    @Nouvel R , what you want can be accomplished in ARM via the following magic incantation:

    {  
        "apiVersion": "2019-08-01",  
        "dependsOn": [  
            "[variables('siteResourceId')]"  
        ],  
        "name": "[format('{0}/slotConfigNames', parameters('siteName'))]",  
        "properties": {  
            "appSettingNames": [  
                "MySettingNameA",  
                "MySettingNameB",  
                "MySettingNameC"  
            ]  
        },  
        "type": "Microsoft.Web/sites/config"  
    }  
    

    Naming is the most important thing here, the resource should be called {siteName}/slotConfigNames and be of the type Microsoft.Web/sites/config. Getting this to work "neatly" takes a bit more fooling around; a full example can be found within the Microsoft.Web-sites template here.

    0 comments No comments

  4. Nick Purington 1 Reputation point
    2021-04-07T20:00:02.827+00:00

    Definitely late to this one, but for anyone still looking for a solution, Azure DevOps has a task that can be added to a release pipeline to do everything @Nouvel R was looking for. I've done some testing and it works great, plus you can just pull the app settings JSON from the portal and paste in the task instead of converting the app settings to "key:value" format in an ARM template.

    azure-app-service-settings

    0 comments No comments