3/03/2014

How to change VM image region (affinity group) in Microsoft Azure

Today, we needed to create a new virtual machine using an existing image in a different region that we worked so far. Due to the fact that images are region specific,we followed the steps above to create the VM:

  • Find the blob URL using Azure Portal. In VM section, there exists three tabs. One of them is images.Click this tab and find your image. Then look at image blob URL( i will call it source blob URL)
  • Create a storage and container in the region that you want to use image if you didnt do. I will call this container as destination base URL
  • Install Microsoft Azure Storage tools. It will be used to copy blob vhd item from one container to another. In current Azure Portal, there is no option to copy blob items. You can also do this by downloading the  vhd and upload it again manually.
azure account import {file path for publishsettings} (you can download publishsettings via shellscript,see next step)
azure vm disk upload {source url} {destination url} {destination storage password}

  •  Install Microsoft Azure ShellScript. It will be used to register your blob as an image.After you execute the command,operating system will be asked, write operating system that the image contains. For my case it was "windows".
 add-azureaccount 
get-azurepublishsettingsfile 
import-azurepublishsettingsfile {file path for downloaded publishsettings}
add-azureVMImage -ImageName {image name} -MediaLocation {destination url} -Label {label of image }


No comments:

Post a Comment