Move Azure VMs between datacenters

Move Azure VMs between datacenters

Recently I had to move a couple of Windows Azures Virtual Machines from West Europe to Southeast Asia. This wasn’t as easy as expected, so therefore i’m sharing the steps on how to move a Virtual Machine to a different data center.

Move Azure VMs between datacenters

The most important part is being familiar with Windows Azures Virtual Machine setup and terminology.

Virtual Machines:

A Virtual Machine in Windows Azure consists out of a computing and storage component (system disks VHDs). The compute instance cannot be moved and therefore needs to be recreated within the desired region/affinity group/virtual network.

VM Storage:

The system disks are located within a storage account, which is bound to a region/affinity group/virtual network. As with the computing instance, the location of a storage account can’t be altered so therefore you will need to transfer the VHD files from one account to another.

Unfortunately this cannot be performed within the current portal but the steps below will guide you through the process

Starting the Virtual Machine “Move” process

Step 1 – Capture Virtual Machine settings

First of all you will need to capture the settings of the target Virtual Machine. The computing instance cannot be moved across data centers; as a result, it’s required to re-create the Virtual Machine instance. Gathering the information can be performed via the Management Portal or just by executing the following PowerShell commands.

In addition you will need to keep track of which VHD file needs to be copied in step 5 format: http://{storage_account}.blob.core.windows.net/{container_for_vhds}/{file_name}.vhd)

Step 2 – Stop and delete the computing instance

Now that the Virtual Machine details have been captured, it’s safe to stop the instance and delete the Virtual Machine and Could Service. Deleting a Virtual Machine will only delete the computing instance, the system disks will remain within the storage container

Step 3 – Create a destination storage account

The next step will be the creation of a new storage account located within the desired region. The following table lists the possible locations:

North Central USSouth Central US
East USWest US
North EuropeWest Europe
Southeast AsiaEast Asia

Step 4 – Copy the system disk’s VHD to the new storage account

We are now ready to start the BlobCopy operation. This operation can only be performed within PowerShell and the Windows Azure REST API. I’ve included the PowerShell version below.

Note: just make sure to provide the storage account name and storage key for both the source and destination. In addition, it’s required to specify VHD file name as gathered in step on and provide a new VHD name for the destination (which can be identical)

Step 5 – Get some coffee and a magazine…

It will take some time to transfer the data. You can keep track of this process using the following PowerShell script:

Or abort the operation:

Step 6 – Create a new Windows Azure Virtual Machine based on the copied VHD

After the data transfer has completed, you should be able to create a new Virtual Machine. Using the portal, select New » Compute » Virtual Machine » From Gallery » My Disks then select your VHD.

Move a Azure VM to a different datacenter

Or using PowerShell

NOTE: Please note that Azure is changing almost on a weekly basis therefore the information in “Move Azure VMs between datacenters” might not be up-to-date.

  • CaptainDDL

    This was really helpful! One thing you may add: I had to create a new container called “vhds” in my new storage account before BlobCopy would run, before that I was getting 404 errors. Thanks again!

    • Kevin Bronsdijk

      Thank you for your feedback! We already provisioned
      some VM’s on the new storage location which explains it. I will include this within the next update.

  • David Gibbons

    Kevin,

    I know this post is a touch old but what if you just wanted to move the VM to a new storage account? Would you still need to remove the machine and recreate it then add all the data disks?

    • Kevin Bronsdijk

      Hi David,

      This should be okay in case the computing instance and
      storage account are both located within the same region. If not, you will have to pay additional data transfer costs. For me, this wasn’t the case, and therefore had to recreate the computing instance. In addition, I wanted to re-use the existing DNS name as well which required me to delete the existing computing instance.

  • Vlad

    Hi there,

    We are developing a tool to greatly simplify the task of movement VMs between datacenters (both on-premise and cloud including Windows Azure)

    See: http://cloudscraper.migrate2iaas.com/azuredownload

    It’s in a beta development stage, so it’s free to use.

    Thanks in advance for giving it a try!

  • Gijs van Dam

    This was helpful, but I got some errors. Maybe because the information is outdated?

    Anyway, what I needed to do to fix it, is adding an AzureDisk before I could create a new VM, based on the .vhd:

    Add-AzureDisk -OS Windows -MediaLocation “http://xxxx.blob.core.windows.net/vhds/[name].vhd” -DiskName “appOSDisk”

    In the confige use DiskName instead of ImageName
    $vmdetails = New-AzureVMConfig -Name “vm_name” -InstanceSize Basic_A2 -DiskName “appOSDisk”

    • Kevin Bronsdijk

      Thank you for your comment.

      I’m not aware of the most recent updates, so this might have been changed. I must say that I prefer the AzureDisk approach as included within your comment, given that the disks most likely won’t be used as base templates. Well, at least for this scenario.

Post Navigation