Move a Windows VM to another Azure subscription or resource group

This article walks you through how to move a Windows virtual machine (VM) between resource groups or subscriptions. Moving between subscriptions can be handy if you originally created a VM in a personal subscription and now want to move it to your company's subscription to continue your work. You do not need to start the VM in order to move it and it should continue to run during the move.

Important

New resource IDs are created as part of the move. After the VM has been moved, you will need to update your tools and scripts to use the new resource IDs.

Use the Azure portal to move a VM to a different subscription

You can move a VM and its associated resources to a different subscription by using the Azure portal.

  1. Open the Azure portal.
  2. Click Browse > Resource groups and select the resource group containing the VM that you would like to move.
  3. At the top of the page for the resource group, select Move and then select Move to another subscription. The Move resources page opens.
  4. Select each of the resources to move. In most cases, you should move all of the related resources that are listed.
  5. Select the Subscription where you want the VM to be moved.
  6. Select an existing Resource group, or enter a name to have a new resource group created.
  7. When you are done, select that you understand that new resource IDs will be created and that the new IDs will need to be used with the VM after it is moved, and then select OK.

Use the Azure portal to move a VM to another resource group

You can move a VM and its associated resources to another resource group by using the Azure portal.

  1. Open the Azure portal.
  2. Click Browse > Virtual machines and select the VM you would like to move from the list.
  3. In the page for the VM, next to the label for resource group, select Change. The Move resources page opens.
  4. Select each of the resources to move. In most cases, you should move all of the related resources that are listed.
  5. Select an existing Resource group, or enter a name to have a new resource group created.
  6. When you are done, select that you understand that new resource IDs will be created and that the new IDs will need to be used with the VM after it is moved, and then select OK.

Use Powershell to move a VM

To move a virtual machine to another resource group, you need to make sure that you also move all of the dependent resources. To get a list with the resource ID of each of these resources, use the Get-AzResource cmdlet.

 Get-AzResource -ResourceGroupName <sourceResourceGroupName> | Format-list -wrap -Property ResourceId 

You can use the output of the previous command as a comma-separated list of resource IDs to Move-AzResource to move each resource to the destination.

Move-AzResource -DestinationResourceGroupName "<myDestinationResourceGroup>" `
    -ResourceId <myResourceId,myResourceId,myResourceId>

To move the resources to different subscription, include the -DestinationSubscriptionId parameter.

Move-AzResource -DestinationSubscriptionId "<myDestinationSubscriptionID>" `
    -DestinationResourceGroupName "<myDestinationResourceGroup>" `
    -ResourceId <myResourceId,myResourceId,myResourceId>

When you are asked to confirm that you want to move the specified resources, enter Y to confirm.

Next steps

You can move many different types of resources between resource groups and subscriptions. For more information, see Move resources to a new resource group or subscription.