How to move Azure Resources to another Resource Group

In many cases, it is necessary to reorganize and move Azure resources to other Resource Groups. Today,  I want to show you how to move an Azure Resource to another Resource Group using Azure PowerShell.

Important: Not all Azure resources can be moved. for more information, check out this link.

This tutorial assumes that you already have a Microsoft Azure account set up.

Azure PowerShell Workaround

If you want to know how to install the PowerShell Azure module on your machine, check out this link.

The simplest way to get started is to sign in interactively at the command line.

This cmdlet will bring up a dialog box prompting you for your email address and password associated with your Azure account.
If you have more than one subscription associated with your mail account, you can choose the default subscription. To perform this task we will use the following commands:

With the following command in PowerShell, we obtain the list of existing resource groups in your subscription.

If you need to create a new resource group, check out this link.

Set the variables

Here, we define the characteristics of our environment and the resource’s properties.

This command obtains the resource in the source resource group.

Move an Azure Resource

To move an Azure Resource using Azure Powershell, you should use the Move-AzResource cmdlet, with the following syntax:

If you want to move the resource to a resource group of another subscription, you must use the -DestinationSubscriptionId parameter. You must replace “My New Subscription” with the name of the destination subscription.

And then use the Move-AzResource cmdlet, with the following syntax:

If you want to move all existing resources within a resource group, you can use the following commands:

Both the source resource group and the target resource group are locked during the move operation. At the end of the process, the Azure Resource will be in the target resource group.

If you want to know more about this topic, check out this link: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-move-resources