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.
It is deployed with Visual Studio Team Services, Release Management using a linked Azure Resource Management Service endpoint.
Once the deployment done to “Deploy” slot, demo-swap-deploy.azurewebsites.net is deployed with simple web application.
Still the main site (Production slot) is shown as just created.
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
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.
Once this is executed, slots get swapped.
After swap “Deploy” slot contains what was in “Production” slot and “Production” slot now has the newly deployed site.
2 comments:
Nice to see a blog dedicated to Azure services , good luck. Keep continuing updating such kind of interested post here.
thank for sharing .
gclub
โกลเด้นสล็อต
Post a Comment