Tuesday, 27 August 2013

Migrate a VM from one region to another

Suppose you are moving a VM from South East Asia to US West region.
Following are the steps required:

  1. Create an affinity group for the required region.



I have named the affinity group as 'WestGroup'.

  2. Create a storage account using this affinity group.



3. Create virtual network

Create a virtual network using the newly created affinity group, and add domain controller for the network. The first machine added to a network will be considered as the DNS server.
The above steps may be avoided if you are moving the VM to an existing network.

4. Copy blob

Now you need to copy the blob of the VM to be moved, to the new storage account. This can be done using some third party tool like Cloud Storage Studio or directly using the Azure PowerShell cmdlet commands.
     Pre-conditions
  • - The disk holding the OS has to be detached before copying the blob. So if there is a VM using the disk, please delete the VM. The VM can be created again if needed.
  • - Also the target storage account should be one created after July 7th of 2012.
a)      In the azure management screen click on the VM that is to be moved. In the Dashboard tab, you will get the names of the disks that are used by the VM.
b)      Click on Virtual Machines on the left pane and then go to the disks tab. You can see the list of all disks together with the VM that it is attached to as well as the location of the blob. You can also identify the disk that contains the OS.
c)       Take note of the blob locations. You can copy it from the locations column. Save these details in a notepad for later reference.
d)      Delete the VM. The associated disks will not be deleted.
e)      Now the blob can be copied to the required storage account.


5. Release lease on the blob

Once the blob is available in the new storage account, release the lease on the vhd. It will take quite some time to get the lease removed.

6. Create a disk using the blob (vhd) that is copied.



Click on create.

Select a VHD url from the new storage account. If the vhd contains OS, check the checkbox. Select the OS and then click on the tick mark.

The new disk is created and will be available in the list of disks after a few minutes.

7. Now you can create a VM using the newly created disk.

Create VM from gallery, using the new disk.  Here you will not be able to select a region different from that of the storage account where the disk is located.




1 comment: