Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deployment slot specific appsettin in ARM template?

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?

like image 440
Volker Avatar asked Oct 30 '16 19:10

Volker


People also ask

What is deployment slot in app service?

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.

How do I deploy an app service to the staging slot?

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

Is it possible to swap appsettings between deployment and slot configuration?

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.

Is it possible to create an Azure web app using arm templates?

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.


Video Answer


1 Answers

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

]

like image 116
Adeel Ilyas Avatar answered Sep 24 '22 10:09

Adeel Ilyas