question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for web app slots

See original GitHub issue

https://docs.microsoft.com/en-us/azure/templates/microsoft.web/2018-02-01/sites/slots

Would also be useful to be able to make app settings “slot sticky”. I can’t find any official documentation or reference but I’ve been using the following in my ARM templates.

{
  "name": "[variables('webAppName')]",
  "type": "Microsoft.Web/sites",
  "apiVersion": "2016-08-01",
  "location": "[resourceGroup().location]",
  "properties": {
    "serverFarmId": "[variables('appServiceResourceId')]",
    "siteConfig": {
      "connectionStrings": [
        {
          "name": "Database",
          "connectionString": "[variables('sqlConnectionString')]",
          "type": "SQLAzure"
        },
        {
          "name": "ServiceBus",
          "connectionString": "[variables('serviceBusConnectionString')]",
          "type": "Custom"
        }
      ],
      "appSettings": [
        {
          "name": "ASPNETCORE_ENVIRONMENT",
          "value": "[parameters('aspNetEnvironment')]"
        },
        {
          "name": "AllowedOrigins",
          "value": "[variables('allowedOrigins')]"
        }
      ]
    }
  },
  "resources": [
    {
      "type": "config",
      "name": "slotconfignames",
      "apiVersion": "2016-08-01",
      "properties": {
        "connectionStringNames": [
          "Database",
          "ServiceBus"
        ],
        "appSettingNames": [
          "ASPNETCORE_ENVIRONMENT",
          "AllowedOrigins"
        ]
      },
      "dependsOn": [
        "[variables('webAppName')]"
      ]
    }
  ]
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
TheRSPcommented, Mar 12, 2021

@isaacabraham I should have a little bit of time coming up and this will soon be a priority for my company.

What do you think about adding these new keywords?

  • slots - takes a string list of slot names (overrides any previous value)
  • zip_deploy_slot - takes a slot name and zip path to deploy to the given slot

Further improvements could then be to add

  • add_slot_setting/add_slot_settings for sticky settings
  • add_slot_connection_string/add_slot_connection_strings for sticky connection strings

Is there an alternative API you would prefer?

1reaction
fraxucommented, Aug 20, 2020

I’m currently using the following quick hack to get slots working.

type Slot =
    { Name : ResourceName
      Location : Location
      SiteName: ResourceName
      ServicePlanName: ResourceName
      AutoSwapSlot: Slot option }
    interface IArmResource with
        member this.ResourceName = this.Name
        member this.JsonModel =
            {| name = sprintf "%s/%s" this.SiteName.Value this.Name.Value
               ``type`` = "Microsoft.Web/sites/slots"
               apiVersion = "2020-06-01"
               location = this.Location.ArmValue
               tags = {||}
               properties = 
                    {| serverFarmId = this.ServicePlanName.Value
                       siteConfig = 
                       {| autoSwapSlotName = this.AutoSwapSlot |> Option.map(fun s -> s.Name.Value) |> Option.toObj |} 
                    |}
            |} :> _

let testWebApp = webApp {
    name "test"
    sku WebApp.Sku.S1
}

let productionSlot = 
    { Slot.Name = ResourceName "production"
      SiteName = testWebApp.Name
      ServicePlanName = testWebApp.ServicePlanName
      Location = Location.WestEurope
      AutoSwapSlot = None }

let stagingSlot =
    { Slot.Name = ResourceName "staging"
      SiteName = testWebApp.Name
      ServicePlanName = testWebApp.ServicePlanName
      Location = Location.WestEurope
      AutoSwapSlot = Some productionSlot }

let deployment = arm {
    location Location.WestEurope
    add_resource testWebApp
    add_resource stagingSlot
    add_resource productionSlot

For basic slots support I guess we would need at least:

  • Custom operator in WebApp builder to make adding slots easy
  • autoSwapSlotName to Site Arm as well
  • Slot builder?
  • Documentation

I’m happy to help with this if needed!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set up staging environments - Azure App Service
In the left pane, select Deployment slots > Add Slot. Note. If the app isn't already in the Standard, Premium, or Isolated tier,...
Read more >
Azure Deployment Slots: Benefits and How to Use Them
In Azure App Services, you can very easily add an additional deployment slot. This is a full-fledged App Service – in this case,...
Read more >
Azure deployment slots
To add a new deployment slot, click Add Slot button at the top. azure app service deployment slots. Provide name for the deployment...
Read more >
azure-content/articles/app-service-web/web-sites-staged- ...
To find out the number of slots your web app's mode supports, see App Service Pricing. ... Then, in the Deployment slots blade,...
Read more >
Azure App Services — Deployment Slots
Let's create a new Slot, for that, go to the App Service and click on “+ Add Slot”, add a name and select...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found