Saturday, November 4, 2017

Azure PowerShell - Cloning App Service Slots

This is some set of scripts I keep using for cloning Azure App Service Slots. Hope someone will find it useful.
# Login
Login-AzureRmAccount
 
# List all subscriptions (this step is only useful if you have multiple subscriptions)
Get-AzureRmSubscription
 
# Select azure subscription (this step is only useful if you have multiple subscriptions)
Get-AzureRmSubscription –SubscriptionName "<SubscriptionName>" | Select-AzureRmSubscription
 
# Listing all slots for a app service
Get-AzureRmWebAppSlot -ResourceGroupName "<ResourceGroupName>" -Name "<AppServiceName>"
 
# Cloning web app to a new slot
$srcWebApp = Get-AzureRmWebApp -ResourceGroupName "<ResourceGroupName>" -Name "<AppServiceName>"
New-AzureRmWebAppSlot -ResourceGroupName "<ResourceGroupName>" -Name "<AppServiceName>" -AppServicePlan "<AppServicePlan>" -Slot "<NewSlotName>" -SourceWebApp $srcWebApp
 
# Cloning web app slot to a new slot
$srcWebAppSlot = Get-AzureRmWebAppSlot -ResourceGroupName "<ResourceGroupName>" -Name "<AppServiceName>" -Slot "<SourceSlotName>"
New-AzureRmWebAppSlot -ResourceGroupName "<ResourceGroupName>" -Name "<AppServiceName>" -AppServicePlan "<AppServicePlan>" -Slot "<NewSlotName>" -SourceWebApp $srcWebAppSlot
Happy Coding.

Regards,
Jaliya

No comments:

Post a Comment