Azure powershell – migrate web apps between resource groups

Simple script to move some web apps between resource groups.


$apps = Get-AzureRmWebApp
$appnames = ($apps).Name
$oldrg = "Old resource group name"
$newrg = "new resource group name"
ForEach ($appname in $appnames) {
$resource = Get-AzureRmResource -ResourceName $appname -ResourceGroupName $oldrg
Move-AzureRmResource -DestinationResourceGroupName $newrg -ResourceId $resource.ResourceId -Force
}

If you want to just move one app.


$resourcename = "Name of web app"
$oldrg = "Old resource group name"
$newrg = "new resource group name"
$resource = Get-AzureRmResource -ResourceName $resourcename -ResourceGroupName $oldrg
Move-AzureRmResource -DestinationResourceGroupName $newrg -ResourceId $resource.ResourceId -Force

Leave a Comment

Your email address will not be published.

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