Copy an Azure Virtual Machine to a different region within Microsoft Azure. One might think this is a big thing (which might become even bigger if the source Virtual Machine uses “Managed Disks”).

The whole process consists of only a few steps (use this as a checklist):

  1. Create Disk Snapshots of the Source Virtual Machine
  2. Copy the Snapshots to a Destination Region-based Storage Account Container
  3. Create a new Virtual Machine within the New Resource Group
  4. Convert the Disks to “Managed Disks“ (if required)

Create Disk Snapshots of the Source Virtual Machine

Creating snapshots is a simple trick: from the Azure Portal select the source VM, select “Disks“, select one of the disks and click “+ Create Snapshot“, and do this for every disk – name them „Snapshot-[VMName]-[DiskDescription]“, for example: “Snapshot-myVM1-OS“ for the System Disk and “Snapshot-myVM1-Data1“ for the first Data Disk. The VM may remain online during this process, but some applications might require the VM to be turned off. Make sure you select “Account type: Premium (SSD) if you use Managed Disks / Premium Storage.

Copy the Snapshots to a Destination Region-based Storage Account

Step Zero again: use the Azure Portal to create a new blob container within a Storage Account in the destination region (used in $DestStorageAccountName and $DestStorageContainerName). All additional steps can be done via Power Shell. Copy Job might take some time. So you should keep the true filesize and speed limit in mind when defining this parameter value. Replace the variables’ values respectively:

# Source Data

$SrcResourceGroupName =”tdv-rg”

$SnapshotName1 = “Snapshot1”

# Destination Data

$DestStorageAccountName = “destinationsnap1”

$DestStorageContainerName = “snapshot”

$DestStorageAccountKey = “1234567897u654wjhluh88y98hihi8y87ujjbut87glig==”

$DestFileName1 = “myNewsnapVM1-OS-VHD.vhd”

# Grant Access to the Snapshots

# Might be necessary if your tenant has multiple subscriptions:

$SubscriptionId = “12345678-e711-49ab-b843-076564532470856erty”

Select-AzureRmSubscription -SubscriptionId $SubscriptionId

$sas1 = Grant-AzureRmSnapshotAccess -ResourceGroupName $SrcResourceGroupName -SnapshotName $SnapshotName1 -DurationInSecond 3600 -Access Read

#Create the context for the storage account which will be used to copy snapshot to the storage account

$DestStorageContext = New-AzureStorageContext –StorageAccountName $DestStorageAccountName -StorageAccountKey $DestStorageAccountKey

#Copy the snapshot to the storage account -> creates background copy jobs, therefore: quick command execution!

Start-AzureStorageBlobCopy -AbsoluteUri $sas1.AccessSAS -DestContainer $DestStorageContainerName -DestContext $DestStorageContext -DestBlob $DestFileName1

#Use this for Copy Job Monitoring – replace X accordingly – use the largest disk for reference

Get-AzureStorageBlobCopyState -Context $DestStorageContext -Blob $DestFileNameX -Container $DestStorageContainerName

#Use this to cancel the Copy Jobs, if necessary

Get-AzureStorageBlob -Context $DestStorageContext -Container $DestStorageContainerName | Stop-AzureStorageBlobCopy –Force

After transferring the snapshot to region B container and create image in region B.

  1. Go to images then provide details like name, resource group, location, OS disk, account type and browse the storage blob to destination file of container.
  2. Create the image from the destination file.
  3. From source region A to destination region B snapshot is transferred. From this image we can create the Virtual Machine in region B.