Slot Swap with Preview

This post has been republished via RSS; it originally appeared at: Azure App Service articles.

First published on MSDN on Dec 12, 2016

Slot Swap with Preview enables us to run production specific app setting and database connection string in a slot website. This allows us to completely test the new deployment with actual production setting. Slot Swap with Preview also allows us to execute warm-up code so that website doesn't have any slow perf issues due to cold start.

There are three main phases in Slot Swap with Preview :

  1. Deploy new code to source slot website
  2. Apply Slot Config : Source slot website recycles and starts with destination slot specific settings (app setting and database connection string).
  3. At this time we can run our test and/or execute warm-up code using source slot website URL.
  4. Note: both destination and source slot website URLs will be running using destination slot specific settings
  5. Complete Slot Swap : if the test is successful, we can complete the swap. Now destination slot website URL will run source slot code with destination slot settings
  6. Reset Slot Swap : if the test fails, we can reset the swap. This will restart source slot website and run under source slot settings

We can do Slow Swap with Preview using Azure Portal as shown below. Note : select the right slot for source.

Here are PS cmdlets to execute Slot Swap with Preview

$AzureWebsiteName = "azinsights"

$AzureRGName = "InternalConsumptionResourceGroup"

$From = "test"

$To = "production"

#Switch-AzureWebsiteSlot -Name $AzureWebsiteName -Slot1 $From -Slot2 $To -Force -Verbose

Switch-AzureRmWebAppSlot -ResourceGroupName $AzureRGName -Name $AzureWebsiteName -SourceSlotName $From -DestinationSlotName $To -SwapWithPreviewAction ApplySlotConfig

Switch-AzureRmWebAppSlot -ResourceGroupName $AzureRGName -Name $AzureWebsiteName -SourceSlotName $From -DestinationSlotName $To -SwapWithPreviewAction CompleteSlotSwap

Switch-AzureRmWebAppSlot -ResourceGroupName $AzureRGName -Name $AzureWebsiteName -SourceSlotName $From -DestinationSlotName $To -SwapWithPreviewAction ResetSlotSwap

Before executing Apply Slot Config PS cmdlets, here are process ID and AppDomain ID of source and destination slot websites :

Production Slot

Test Slot

After executing Apply Slot Config PS Cmdlet, test slot website recycled and now using production database. Destination slot is untouched.

Production Slot

Test Slot

After executing Complete Slot Swap PS Cmdlet, production slot website has same process id as previous test slot website . And the new test slot website recycled and now using test database.

Production Slot

Test Slot

More Info

Azure Web App Deployment Slot Swap with Preview
Using PowerShell to manage Azure Web App Deployment Slots

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.