I'm trying to get into that Visual Studio Resource Group template. So far it's looking good, and I have added some appsettings for a web app, but my question is, how can I make them deployment slot specific? Is there something in the json for the template or the parameter file?
Deployment slots are in fact resources of the App Service itself and can be deployed as such. This means you can specify them within the resources array of your web application / App Service. ARM code for deployment slot looks like below: Here, slot name is defined inside a property named stagingSlotName.
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
The accepted answer is correct, but leaves out an important piece of information. Under its current implementation, when swapping slots the AppSettings configuration for the slot will be swapped along with the deployment. If you are concerned about slot-specific configuration then this probably is not desirable for you.
While creating an azure web app or app service is not that tricky, usually you would require additional settings like deployment slots, application settings, connection strings, custom time zone etc. as well. It would be certainly nice if we can incorporate some of that as part of ARM templates itself so that we need not worry about it later.
"slotconfignames" should only be specified on production slot to tell which settings that are slot specific even if they don´t even exist on the slot. The actual value for the slot specific setting should still be specified on the slot settings.
"resources": [
{
"apiVersion":"[variables('siteApiVersion')]",
"name":"[variables('WebAppName')]",
"type":"Microsoft.Web/sites",
"kind":"api",
"location":"[variables('location')]",
"tags":{
"[concat('hidden-related:', resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName')))]":"empty"
},
"properties":{
"name":"[variables('WebAppName')]",
"serverFarmId":"[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
"siteConfig":{
"AlwaysOn":"[parameters('AppServiceAlwaysOn')]"
}
},
"resources":[
{
"apiVersion":"[variables('apiVersion')]",
"type":"config",
"name":"appsettings",
"dependsOn":[
"[variables('WebAppName')]"
],
"properties":{}
},
{
"apiVersion":"[variables('siteApiVersion')]",
"type": "config",
"name": "slotconfignames",
"dependsOn": [
"[concat('Microsoft.Web/sites/', variables('WebAppName'))]"
],
"properties": {
"appSettingNames": [ "WEBJOBS_DISABLE_SCHEDULE" ]
}
},
{
"apiVersion":"[variables('siteApiVersion')]",
"condition":"[parameters('stagingSlotEnabled')]",
"name":"[parameters('stagingSlotName')]",
"type":"slots",
"tags":{
"displayName":"[concat(variables('WebAppName'), ' ', parameters('stagingSlotName'))]"
},
"location":"[variables('location')]",
"dependsOn":[
"[resourceId('Microsoft.Web/Sites', variables('WebAppName'))]"
],
"properties":{},
"resources":[
{
"apiVersion":"[variables('apiVersion')]",
"type":"config",
"name":"appsettings",
"dependsOn":[
"[resourceId('Microsoft.Web/Sites/Slots', variables('WebAppName'), parameters('stagingSlotName'))]"
],
"properties":{
"WEBJOBS_DISABLE_SCHEDULE" : "1"
}
}
]
}
]
}
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With