Move VMs from & to anywhere in Azure

Automatically move VMs from anywhere & to anywhere in Azure:

  • Move VMs across subscriptions
  • Move VMs across tenants
  • In the same region or across regions
  • No downtime on the source VM (if there’s no data disks), the source VM remains in-tact
  • Copies both the OS disk and any data disks attached to the VM
  • Both Standard & Premium managed disks supported


Works with ARM Managed Disk based VMs only. This script is fully automatic and cleans up temp disks & storage accounts at the very end. It shows the copy process and doesn’t waste time by coping white space on disks (e.g. if you had a 1023GB disk and only 1GB was in use, the time it takes to copy 1GB of data). If you had multiple data disks attached to a VM, this script keeps a track of the disk LUN numbers, when you re-attach the disks at the end using the Azure portal, you simply attach the data disks in the order of the LUN number specified on the data disks.



  • Run the script
  • It prompts you for source & target credentials & subscriptions
  • prompts you to select a source VM from a list of managed disk based VMs
  • prompts you to select a target region from a list of Azure regions
  • prompts you to enter a target resource group
  • It will prompt you to shut down the source VM if there’s data disks, it can’t possibly copy all the disks in sync, the end state will be un-comprehensible.

This script sets up the target resource group along with exact copies of managed disks from the source VM. The script uses its own naming convention for the target disks as per the screenshot above (with the date tacked on the end). From there, you manually create the new VM using the Azure portal and attach the disks back to the VM and follow the process of creating a normal VM in the Azure portal.

In the Azure portal on the OS managed disk blade, choose the option to ‘Create VM‘ and and follow your nose to create a VM in the Azure portal, then attach any data disks in the order of LUN IDs specified in the data disk display names (starting at xero).


If you have issues with the script below (errors etc), check first the very top line and install the same PowerShell module that I wrote the script with.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s