Sio
Sio

Reputation: 1441

Retain Current AppSettings for Production Azure Function Slot in ARM

I'm looking to implement a staging slot for an Azure function. The approach I'm attempting to take is to define the slot in the ARM template along with the rest of the infrastructure and the app settings. I'll then deploy the app to the staging slot and perform a slot swap using az.

The problem I have is that the app settings sometimes contains settings specific to the version of the app running. Within the ARM template, I want to apply new application setting to the staging slot whilst retaining the currently set value for some of the settings on the production slot. These production slot settings should then only be updated when the swap occurs in the next couple of steps.

I've not been able to find a way to express this within ARM. I've attempted to use reference to set the appsetting property to be its current value. I'm not sure if this is possible but I get a generic validation error with no detail on why it's failed.

Is there a way to leave some appsettings unchanged in ARM?

UPDATE

Here is a snippet of my attempt to retain the existing value of the config.

{
    "type": "Microsoft.Web/sites/config",
    "name": "MyApp/appsettings",
    "apiVersion": "2019-08-01",
    "properties": {
        "MY_APP_CONFIG1": "[reference(resourceId('Microsoft.Web/sites/config', 'MyApp', 'appsettings'), '2019-08-01', 'Full').properties.MY_APP_CONFIG1]"
    }
}

The reference function introduced here fails the template validation. Only information it gives me is The deployment validation failed.

Upvotes: 0

Views: 657

Answers (2)

Jeck Hunter
Jeck Hunter

Reputation: 1

I've found following call:

"value": "[list(format('{0}/config/appsettings', variables('funID')), '2020-06-01').properties.MY_APP_CONFIG1]"

Hope it will be usefull.

Upvotes: 0

4c74356b41
4c74356b41

Reputation: 72181

no, you have to set all of them in the template. to pass different values to the template you are using to deploy to different environments (slots) you can use parameters (or parameter files). you can probably get a reference of the current value with the reference(xxx, xxx, 'Full')

https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-resource#reference

Upvotes: 0

Related Questions