Tuesday 30 August 2016

Azure Web App Swap Slot–With VSTS Release Management using Azure RM

Using deployment slots in Azure is very useful when it comes to production deployments. You can deploy to a deployment slot and then verify and swap the slot with production.

Azure App Service site created with a slot called Deploy.image

It is deployed with Visual Studio Team Services, Release Management using a linked Azure Resource Management Service endpoint.

image

Once the deployment done to “Deploy” slot, demo-swap-deploy.azurewebsites.net is deployed with simple web application.image

Still the main site (Production slot) is shown as just created.image

Azure Resource Manager command “Invoke-AzureRmResourceAction” can be used in PowerShell to swap the slot.

param($resourceGroupName, $websiteName, $slotName, $targetSlotName)

$ParametersObject = @{targetSlot  = $targetSlotName}
Invoke-AzureRmResourceAction -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Web/sites/slots -ResourceName $websiteName/$slotName -Action slotsswap -Parameters $ParametersObject -ApiVersion 2015-07-01 -Force

image

Script requires following parameters.

-resourceGroupName "ch-demo-resgroup" -websiteName "Demo-Swap" -slotName "Deploy" -targetSlotName "Production"

  • resourceGroupName – Resource Group Name of the Web App
  • websiteName – Web App Name
  • slotName – Slot Name
  • targetSlotName – target Slot

This script can be setup to execute with Azure PowerShell task, in release management.image

Once this is executed, slots get swapped.image

image

After swap “Deploy” slot contains what was in “Production” slot and “Production” slot now has the newly deployed site.image

image

2 comments:

Unknown said...

Nice to see a blog dedicated to Azure services , good luck. Keep continuing updating such kind of interested post here.

Anonymous said...

thank for sharing .
gclub
โกลเด้นสล็อต

Popular Posts