In Focus

Deployment Slots In Azure Web Apps - Part Two (Swap)

This article is a continuation of part one in which we created and deployed Web apps into a slot. Here, we will see how to swap the contents between the two slots.

In the first part, we saw how to create and deploy a Web app to a slot and now let us see how to work with it. Now, we have multiple slots for the production and testing and after the testing process is over, everyone is happy with your development slot app and they want it to go live in the production slot.

Azure makes it easy as there is a cool feature called Swap in the dashboard, which will enable you to simply swap the contents from the slot.

 

The swapping will swap the entire contents of the two slots. It is not just putting the contents from the development to the production, instead it will also copy the content from the production to the development also.
 
 

As we only have two slots here you may have to select the slots accordingly.

Note

We can see the name development, which we have given by our self but not aware of the production name. An Azure itself will give the production name to the default slot.

On completion, if you check both the URL's, you can see that the contents have been swapped between the two URL's.

 
 
 

This is a cool feature from Microsoft Azure, as it enables you to test in the isolated mode. The only catch here is the database strings. You want to change the database string while swapping otherwise there will be collision.

Powershell command for swapping is given below.

  1. Switch-AzureWebsiteSlot -Name "ramees" -Slot1 "production" -Slot2 "development"