My Demo Machine

I have a reasonably powerful laptop that I use for demos.  I also use VMware Player because it’s free, because I have experience with VMware, and because I want virtual machines for demos.  That way, I can keep my demonstration environment fairly well controlled.  I don’t upgrade my demo machines that often, and when I do, I’m reasonably careful about it.  This also allows me to repeat my demonstrations without too much bother, and it also means that my futzing about with other work doesn’t affect my ability to demo presentations.

My Mistake

Just about two months ago, I had disaster befall me at SQL Saturday Pittsburgh, when my laptop and the provided projector absolutely would not play nice.  I had a tablet with me, but there’s no way my little tablet would be able to power SQL Server, even if I had it installed.  What that tablet can do, though, is run a VM.  I also have an Azure subscription, so I decided that one of my many safety measures would be to migrate my demo VM up to Azure so that I could spin up a VM in the event of future disaster.

Approaches

There are two approaches that will work:  the Microsoft Virtual Machine Converter and manually uploading VMs.  I’ll walk through each.

Microsoft Virtual Machine Converter

There are a few good resources on how to get MVMC working.  I started with Carsten Lemm’s blog post on the topic because I wanted to migrate a VMware VM into Azure and I could afford to spend 30 minutes on the task.  Sadly, my experience took well over 30 minutes…

After downloading and installing the MVMC executable, I followed Carsten’s instructions and made sure that my VM obtains DNS and IP addresses automatically rather than hard-coding addresses.  I also turned on Remote Desktop.  At that point, Carsten’s blog post is a bit out of date, as he references an executable which no longer exists.  But that’s okay, because the MVMC 3.0 executable now has a nice wizard.  The route is pretty simple: on the first screen, we want to select the “Virtual machine conversion” radio button.  Then, select the “Migrate to Microsoft Azure” option and hit Next again.  The next tab asks you for a Subscription ID and Certificate Thumbprint.

To get the Subscription ID, you can go to the old Azure portal and click the Settings tab on the left-hand navigation bar.  That will give you a GUID which represents your subscription ID.  Copy and paste that into the Subscription ID section and you will find a bug:  this page has an off-by-one error.  If you paste in your subscription ID, you’ll see that the last character is missing and the app does not allow you to type in that last character.  Even if you delete characters, you’re still stuck.  The only way I was able to get past this is to type in my GUID manually.

As for the Certificate Thumbprint, the same applies:  I needed to type it in manually or else the app would cut off part of the thumbprint.  Don’t type in any of the spaces and you’ll be fine.  If you don’t know how to create a certificate, check out the Additional Resources section.

From here, I’m going to cut out because the next screen ended up being my downfall:  they want me to put in my VCenter, ESX, or ESXi server name.  I don’t have one of those; I’m just using VMware player and want to convert my VMDK files to VHDs so Azure can use them.  I realized at this point that MVMC was not the trick.  The only reason I’m including this section is to point out the bug above, just in case anybody gets errors like The certificate with thumbprint [thumbprint] was not found in the personal certificate store.  If you know that you’re copy-pasting correctly but it’s still giving you that error, type the thumbprint out and see how that goes.

Manual VM Upload

From here, I decided to cut my losses and start over without MVMC.  The first step is that you need to run sysprep on the VM.  If you don’t do this, the image will fail to provision and you might not be able to use the Azure VM you create.  Sysprep is available in the Windows\System32\Sysprep directory, and has a GUI.  In my case, I decided to copy my VM folder to ensure that it didn’t mess up the local copy of my demo box VM.  The last thing I want is for my Azure copy to mess up my local copy.  Anyhow, run sysprep.exe to begin sysprep.

Once sysprep’s GUI appears, select the “Enter System Out-of-Box Experience (OOBE)” drop-down option and check the “Generalize” checkbox, and then select the “Shutdown” drop-down menu item from the Shutdown Options list.  Let sysprep do its thing, and then it’ll shut down your VM.

Once sysprep was done, I needed to find a way to get the VMDK files converted to VHDs.  A blog post turned me on to StarWind Software’s V2V Converter.  It’s a free tool which allows you to convert virtual hard drive files from one format to another.  Installing this tool let me turn my set of VMDKs into one 45GB VHD.  One note is that, at least on my machine, I needed to run the V2V Converter from a command prompt; executing the app directly from the Start menu would cause the app to appear for a moment and then disappear, as though some error killed the program.  The tool installs by default in “%programfiles(x86)%\StarWind Software\StarWind V2V Image Converter\StarV2V.exe” From there, I just needed to get that big image into Azure.

Make sure that you have the Microsoft Azure Powershell cmdlets.  Then, follow these instructions to connect your Azure subscription to the local machine and upload your VHD using the Add-AzureVhd cmdlet.  Make sure that you have a Storage object and a Blob container, as that’s where you’re going to store the VHD file from which you’ll make a Virtual Machine image.

Once you have that image uploaded, you can create a new Azure VM from an image.  Select the “MY IMAGES” option and you can pick your demo image.  It’ll take a while for the VM to be provisioned.  Also, don’t forget that you’re going to be charged for that VM as long as it’s running, so if you’re not using it, turn that sucker off.

Conclusion

I wanted a nice and easy GUI that let me tell an app where my VMDK files were and let it do all of the preparation, conversion, uploading, image creating, and provisioning.  You aren’t going to get that.  For these types of one-off scenarios, I accept (but am not happy with) the second approach listed.  If I were doing this in an enterprise environment, there’d be a lot more Powershell.

Additional Resources

MVMC

Manual VM Upload

Advertisement

One thought on “Migrating A Virtual Machine To Azure

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s