This article is about moving resources to another subscription or another resource group in the same subscription. This can be done using Azure portal, PowerShell, Azure CLI or the REST API.
To move resources, the source resource group and the target resource group both are locked during the operation and resources can’t be added, updated, or deleted in the resource groups but they are not frozen. For example, if a SQL Server is moved to a new resource group, the applications using the database will not experience any downtime. They would still be able to access the database(s). However, changing the location of the resource is not possible.
Below are the ways to move the resources:
Using Azure Portal
-
- Select the resource group containing the resources to be moved, and then click on Move.
- Chose the option from moving the resources to another resource group or another subscription.
- Select all those resources that are to be moved.
- Select the destination resource group. Acknowledge the message by clicking on checkbox before it and then click OK. You may even create an new resource group by clicking on “Create a new group”.
- The resources will start moving and notification is created on completion.
- Select the resource group containing the resources to be moved, and then click on Move.
Using PowerShell
In PowerShell, the Move-AzureRmResource command is used to move existing resources to another resource group or subscription.
Syntax:
Move-AzureRmResource -DestinationResourceGroupName NewRG -ResourceId
To move to a new subscription, include the DestinationSubscriptionId parameter in the above command.
Using Azure CLI
The az resource move command is used to move existing resources to another resource group or subscription, using Azure CLI. Provide the space-separated list of the resource IDs of the resources to move. The following example shows how to move multiple resources to a new resource group, in the –ids parameter.
Syntax:
az resource move –destination-group newgroup –ids $resource $plan
To move to a new subscription, provide the –destination-subscription-id parameter.
Using REST API
To move existing resources to another resource group or subscription, use the following post request
POST https://management.azure.com/subscriptions/{source-subscription-id}/resourcegroups/{source-resource-group-name}/moveResources?api-version={api-version}
Specify the target resource group and the resources to move in the request body.