One of the common tasks as an azure administrator you should know it when you deployed azure resource on resource group related for testing as example and you need to move it to new resource group or resource group of production we can do this activity with one PowerShell command and if you are not interested in PowerShell don’t worry you can do also from Azure Portal.
Alert 💣:Moving Azure resource will create new resource id this meaning if you any subscription or APP referencing this resource-id it will break be caution ✍ (Read More, Document the Steps, Test the Steps ) then do your implementation
To know more information about azure services check my (Latest Microsoft Azure Articles and Posts)
Moving Azure Resource Using Azure Portal
Open Microsoft Azure Portal select the source resource group and from the top, you have two option (Move or Change) both you will direct you to move your resource by the selecting the resource you need to move it then the new resource group (Destination) during this steps you can create new resource group easily.
Moving Azure Resource using PowerShell
To move Azure Resource with Powershell we need at least 3 information:
- Resource ID: For the Azure resource you need to move
- Resource Name: Azure Resource name for the resource you need to move it
- Destination resource Group: New Resource group you will move your azure resource to it.
PowerShell Command Explanation
- The first command I will try to show the resource information I need to move it to new resource group (It is Azure SQL Database Resource)
- The second command I will create PowerShell Variable and I will fill it by the resource id for the Azure SQL DB resource that I need to move it
- The third command testing the PowerShell Variable to check it is returned the correct resource Id
- The last command is moving the resource from the current resource group to a new resource group
---First Command get-azresource -ResourceGroupName cbt103resourcegroup1 -ResourceType Microsoft.Sql/servers ---Second Command $rsid = (Get-AzResource -ResourceGroupName cbt103resourcegroup1 -ResourceName elmasryazuresql).resourceid ---Third Command $rsid --- last Command Move-AzResource -DestinationResourceGroupName prodresourcegroup -ResourceId $rsid
Congratulation your resource moved to new resource group with one PowerShell command in less than 5 Minutes.
Check Moving Process Log
During this activity or after it if you need to validate what is happened behind the sciences you can log into Source resource group and in the left side check the activity log you will find the moving and delete activity for the resource in the other side if you go to the destination resource group and check in the left side the activity log you will find the creating process of the resource you are moved it