On March 12, 2014 I was the featured guest on the Azure Podcast Episode 19.
Here is a summary of that conversation:
As some of you may know I am a Windows Azure Consultant and a Cloud Technical Solutions Specialist working with an internal Microsoft product team based out of N3, an Atlanta based consulting firm. We handle questions from people who sign up for Azure Free Trials and who attend Azure public events.
We have a hierarchy of support people in our team: Qualifiers that will contact you to see if you need any help and then pass you on to our 1st level technical support that will try to answer any technical questions that you have. If they can’t answer the question then it gets escalated to my team. We have folks all over the world in places like Scotland, Germany Russia, Italy and of course the US. So we have most time zones covered.
Understanding what a VM is
The key to moving a VM anywhere is to understand what a VM really is in Windows Azure. A VM is based on a VHD image persisted in a Page Blob. When you create a VM it locks on to the underlying Page Blob. There are two kinds of VHDs Syspreped VHDs that you want to use to create multiple similar VMs and non-Syspreped VHDs that you just want to install
One of the things that comes up frequently is how to move a Virtual Machine from one “place” to another. The desired target could be another Virtual Network, Cloud Service, Subscription or even another data center or geographic region.
The first piece of advice that I would give you is don’t! Don’t get yourself into the position of having to move a VM in the first place!
I know that we make it pretty easy to just jump in and just create a VM ignoring things like Virtual Networks, Cloud Services and DNS. And to get some early experience that is fine. But when it comes to doing something for real then you should do some advance planning to put things where you need them.
Now that being said there are use cases where you do really need to move things around. In some cases you can get some help from Windows Azure Support but it is always a good Idea to be able to do it yourself.
How to Move
To move the VHD to another location Stop(Deallocate) and delete the old VM but remember not delete any of the attached disks (one of which is the OS disk). That will release the lock on the Blob. Then look in storage to find the VHD in the VHDs container in your Storage Account.
If you need to move it outside of the current subscription, for instance to another subscription or even another data center, then you need to get it to the remote location. You can copy the underlying Blob to the remote subscription using the new Async Blob Copy command or a third party utility like Cerebrata or Cloudberry. (Note: If all you want to do is move the VM to another subscription you can contact Microsoft Windows Azure Support and they can do that for you since that just involved a table change inside of Windows Azure.)
Once the Blob is moved to its new location you can recreate the OS disk from the Blob URL using Virtual Machines -> Disks -> Create Disk and then Create the VM with New-> Virtual Machine -> From Gallery Selecting MyDisks to pick the disk you just created. If you are just moving it to another Virtual Network in the Same subscription you can omit the first step of creating the Disk. Since it will already be there.
Remember to set appropriate permissions on the Blob using Shared Access Signature before you copy it if necessary.
Obviously if you are going to do this a lot PowerShell will be your best friend. In fact there are some PowerShell scripts out there that you can take and adapt for this. And the new SDK Upload command will work where the source and destination are both in Azure. In fact the Windows Azure Script Center is a great resource that you should become familiar with. Lots of good ideas there. (My thanks to Jean-Claude Grattery from N3 for pointing it out to me.)
Like I said in the beginning, it is good to know how to do this, but even better to plan ahead to avoid having to do it. Because it is a hassle.
The Azure Podcast web site for the download also contains some links to Windows Azure information sources that may prove useful to you.