Impact of azure deployment slot swap on application configuration settings


In our previous video, we discussed deployment slots, how to create and their use. In this video we will discuss what happens to application configuration settings such as a database connection string for example, when we swap deployment slots in azure. 

Deployment Slots - Default Behaviour

azure deployment slots configuration

Let's say we have two deployment slots - staging and production. Staging slot points to the staging database and production slot points to the production database. Now, let's say we make a change to our application code. We deploy the new version of the application on the staging slot. We do all our testing. If we are happy with the results, we promote the build to production. The way we do this in azure is by swapping the two slots - staging to production and production to staging. 

Upon swapping the slots, by default, along with the content, some application configuration settings like the database connection strings are also swapped. So this means, production slot is now pointing to the staging database and the staging slot is pointing to the production database. 

azure deployment slots swap

This is definitely not the behaviour we want. Even after the swap, production slot should be pointing to the production database and staging slot should be pointing to the staging database.

azure deployment slots swap database connection string

Deployment Slot Setting

We want the database connection string to stick with the slot. We do not want it to be swapped during the swap operation. So to make the database connection string or any application configuration stick with the slot 

  1. Navigate to either production or staging deployment slot
  2. Under Settings section, cick on the Configuration tab
  3. Click on the Edit icon to edit the database connection string
  4. Check the checkbox - Deployment slot setting

azure deployment slot setting

With this setting in place, database connection strings are not swapped when the slots are swapped. So staging slot will always point to the staging database and production slot will always point to the production database.

Azure tutorial for beginners





© 2020 Pragimtech. All Rights Reserved.