Migrate VM with Managed Disks to another Azure subscription - addycluri/Azure GitHub Wiki

Migrating Azure Resources to another subscription using Resource Move

If you need to migrate azure resources across different subscriptions, either within the same tenant/Directory or even across tenants, the resource move feature from the Azure portal can be very useful however, it has quite a few limitations based on the type of resources you are trying to migrate.

This wiki particularly focuses on the process of migrating Virtual machines with the managed disks to another subscription in your efforts to moving Azure resources from EA (Enterprise Agreement) or PAYG (Pay-as-you-go) to CSP (Cloud Solutions Provider)

Migration Steps

Unlike other Azure resources, Migrating Virtual machines with the managed disks is not straightforward as the disks attached to the VM's must first be converted from managed --> unmanaged like mentioned in the Azure Resource Move VM Limitations only after which the VM can be migrated. Below is the E2E guidance for converting the disks and migrating the VM from subscription A to subscription B

  • Download and import the Powershell Module locally using the instructions provided - here

  • Open PowerShell and run Get-Help Convert-ManagedDiskToUnManaged -Full to get an understanding of how the function works and the input parameters required.

  • Login to your source azure account using Connect-AzureRmAccount -TenantId "GUID" -SubscriptionId "GUID" (where the VMs with managed disks currently live)

  • Now convert the managed disks to un-managed using the commmand - Convert-ManagedToUnManaged -VMName "MY-VM" -ResourceGroupName "MY-RG" -verbose. Please be advised that this process requires VM's to be turned off so plan accordingly

  • After the successful conversion, the VM (with unmanaged disks) will support Azure resource move functionality.Please follow the Resource Move steps described here and move the VM to the target subscription.

  • After the VM is successfully migrated to the target subscription, you can convert the VM back to "managed" by following the steps below:

    • Ensure the powershell module downloaded from here is imported into the current Powershell session
    • Login to the target azure account using Connect-AzureRmAccount -TenantId "GUID" -SubscriptionId "GUID" (this is where you have migrated VMs to)
    • Now convert the un-managed disk back to managed using the commmand - Convert-UnManagedToManaged -VMName "MY-VM" -ResourceGroupName "MY-RG" -verbose. Please be advised that this process requires VM's in the av-set to be turned off so plan accordingly

References

Export VM disk mapping

⚠️ **GitHub.com Fallback** ⚠️