Partager via


Slot Swap with Preview

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.

Protal_SlotSwapPreview

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

2_Before_Prod 2_Before_Test

 

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

Production Slot

Test Slot

2_Before_Prod 2_After_Test

 

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

2_Complete_Prod 2_Complete_Test

 

More Info

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

Comments

  • Anonymous
    December 12, 2016
    Hi, is this feature ready to use in production environment? I saw it before but it was in preview and there was a suggestion to not use it in production environment.
    • Anonymous
      December 13, 2016
      yes, this feature is production ready.
  • Anonymous
    April 05, 2017
    It would be really helpful if the official documentation included the same detail as in this blog post. It took me a while to find this information. Thanks!