Migrating A Virtual Machine To Azure

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

OneNote search problems and how to fix them

With Kevin posting about video games, I figured I would post about computers, in a hilarious role reversal that may last as long as one post.

As many of you may know, I am working on my dissertation. I use Microsoft OneNote to organize my digital notes for a few reasons. First, it saves everything instantly. Second, it plays nicely with other Office applications. But thirdly, and most importantly, it has a powerful search feature that I have come to depend on. I can type a few words into my search box and it will bring up everything I’ve put into my dissertation notebook. It will also helpfully include partial words, as in this incredibly mature search:

2015-12-05 23_24_10-Action center

The section you’re looking at is called “Pin search results,” and it’s amazing. It shows me every appearance of a word (or part of a word), in context, which helps me find what I need quickly.

There is a downside to this beneficent program. Every so often, the search index gets corrupted. I couldn’t figure out what was happening, so I went to the internet. As this problem had occurred once before, I had some idea of what to look for, so first I decided to rebuild my search index. It’s somewhat time consuming, but it worked before, so I did it again. After another search, however, I found this website, which has an even better solution: to delete OneNote’s cache and force the program to rebuild it.

I am now happily searching again. If it doesn’t last, I will report back here.

 

Making Music With SQL Server

This is an old post, but I’m turning Thomas Rushton’s idea into a lightning talk for the .NET User Group.  Basically, the idea is that you can call Console.Beep with different pitches and for different lengths of time, with the end result being music.

I’m also going to demo the Super Mario Brothers theme.  Here’s a C# version.  The quick translation to Powershell is:

[console]::beep(659, 125);
[console]::beep(659, 125);
Start-Sleep -m 125;
[console]::beep(659, 125);
Start-Sleep -m 167;
[console]::beep(523, 125);
[console]::beep(659, 125);
Start-Sleep -m 125;
[console]::beep(784, 125);
Start-Sleep -m 375;
[console]::beep(392, 125);
Start-Sleep -m 375;
[console]::beep(523, 125);
Start-Sleep -m 250;
[console]::beep(392, 125);
Start-Sleep -m 250;
[console]::beep(330, 125);
Start-Sleep -m 250;
[console]::beep(440, 125);
Start-Sleep -m 125;
[console]::beep(494, 125);
Start-Sleep -m 125;
[console]::beep(466, 125);
Start-Sleep -m 42;
[console]::beep(440, 125);
Start-Sleep -m 125;
[console]::beep(392, 125);
Start-Sleep -m 125;
[console]::beep(659, 125);
Start-Sleep -m 125;
[console]::beep(784, 125);
Start-Sleep -m 125;
[console]::beep(880, 125);
Start-Sleep -m 125;
[console]::beep(698, 125);
[console]::beep(784, 125);
Start-Sleep -m 125;
[console]::beep(659, 125);
Start-Sleep -m 125;
[console]::beep(523, 125);
Start-Sleep -m 125;
[console]::beep(587, 125);
[console]::beep(494, 125);
Start-Sleep -m 125;
[console]::beep(523, 125);
Start-Sleep -m 250;
[console]::beep(392, 125);
Start-Sleep -m 250;
[console]::beep(330, 125);
Start-Sleep -m 250;
[console]::beep(440, 125);
Start-Sleep -m 125;
[console]::beep(494, 125);
Start-Sleep -m 125;
[console]::beep(466, 125);
Start-Sleep -m 42;
[console]::beep(440, 125);
Start-Sleep -m 125;
[console]::beep(392, 125);
Start-Sleep -m 125;
[console]::beep(659, 125);
Start-Sleep -m 125;
[console]::beep(784, 125);
Start-Sleep -m 125;
[console]::beep(880, 125);
Start-Sleep -m 125;
[console]::beep(698, 125);
[console]::beep(784, 125);
Start-Sleep -m 125;
[console]::beep(659, 125);
Start-Sleep -m 125;
[console]::beep(523, 125);
Start-Sleep -m 125;
[console]::beep(587, 125);
[console]::beep(494, 125);
Start-Sleep -m 375;
[console]::beep(784, 125);
[console]::beep(740, 125);
[console]::beep(698, 125);
Start-Sleep -m 42;
[console]::beep(622, 125);
Start-Sleep -m 125;
[console]::beep(659, 125);
Start-Sleep -m 167;
[console]::beep(415, 125);
[console]::beep(440, 125);
[console]::beep(523, 125);
Start-Sleep -m 125;
[console]::beep(440, 125);
[console]::beep(523, 125);
[console]::beep(587, 125);
Start-Sleep -m 250;
[console]::beep(784, 125);
[console]::beep(740, 125);
[console]::beep(698, 125);
Start-Sleep -m 42;
[console]::beep(622, 125);
Start-Sleep -m 125;
[console]::beep(659, 125);
Start-Sleep -m 167;
[console]::beep(698, 125);
Start-Sleep -m 125;
[console]::beep(698, 125);
[console]::beep(698, 125);
Start-Sleep -m 625;
[console]::beep(784, 125);
[console]::beep(740, 125);
[console]::beep(698, 125);
Start-Sleep -m 42;
[console]::beep(622, 125);
Start-Sleep -m 125;
[console]::beep(659, 125);
Start-Sleep -m 167;
[console]::beep(415, 125);
[console]::beep(440, 125);
[console]::beep(523, 125);
Start-Sleep -m 125;
[console]::beep(440, 125);
[console]::beep(523, 125);
[console]::beep(587, 125);
Start-Sleep -m 250;
[console]::beep(622, 125);
Start-Sleep -m 250;
[console]::beep(587, 125);
Start-Sleep -m 250;
[console]::beep(523, 125);
Start-Sleep -m 1125;
[console]::beep(784, 125);
[console]::beep(740, 125);
[console]::beep(698, 125);
Start-Sleep -m 42;
[console]::beep(622, 125);
Start-Sleep -m 125;
[console]::beep(659, 125);
Start-Sleep -m 167;
[console]::beep(415, 125);
[console]::beep(440, 125);
[console]::beep(523, 125);
Start-Sleep -m 125;
[console]::beep(440, 125);
[console]::beep(523, 125);
[console]::beep(587, 125);
Start-Sleep -m 250;
[console]::beep(784, 125);
[console]::beep(740, 125);
[console]::beep(698, 125);
Start-Sleep -m 42;
[console]::beep(622, 125);
Start-Sleep -m 125;
[console]::beep(659, 125);
Start-Sleep -m 167;
[console]::beep(698, 125);
Start-Sleep -m 125;
[console]::beep(698, 125);
[console]::beep(698, 125);
Start-Sleep -m 625;
[console]::beep(784, 125);
[console]::beep(740, 125);
[console]::beep(698, 125);
Start-Sleep -m 42;
[console]::beep(622, 125);
Start-Sleep -m 125;
[console]::beep(659, 125);
Start-Sleep -m 167;
[console]::beep(415, 125);
[console]::beep(440, 125);
[console]::beep(523, 125);
Start-Sleep -m 125;
[console]::beep(440, 125);
[console]::beep(523, 125);
[console]::beep(587, 125);
Start-Sleep -m 250;
[console]::beep(622, 125);
Start-Sleep -m 250;
[console]::beep(587, 125);
Start-Sleep -m 250;
[console]::beep(523, 125);
Start-Sleep -m 625;

And let’s not stop there:  play the Imperial March if you wish.

uMatrix

Not too long ago, I was using ScriptSafe selectively to block Javascript on webpages.  Back in about June, that started breaking Google searches, and I had to abandon it—which makes sense because it looks like ScriptSafe itself has been abandoned.  Since then, I’ve come upon my new Javascript blocker of choice:  uMatrix.  uMatrix is definitely more advanced and fine-grained than ScriptSafe, but I think it succeeds on its premise a bit better.

One of the things uMatrix does out of the box is allow first-party Javascript to run.  This means that fewer sites will be broken-by-default.  You also get the chance to enable or disable Javascript by domain.  This means that I can enable plus.google.com scripts when I’m using GMail, but I don’t need to open myself up when I’m on an external site.  The matrix concept took a little bit of time getting used to, but I don’t think I want to go back.  uMatrix can also block images, CSS files, plugins, scripts, and iframes from certain domains, meaning that you can let images through a third-party domain but block scripts.  That isn’t really as useful as it seems, but it’s a nice concept.

Also nice is that there’s support in Firefox and Chrome, meaning that I can get the same experience across both browsers.  No IE/Edge support, though.

Windows Live Writer Is Still Alive

Not too long ago, I decided to start blogging regularly once more.  In order to do this, I want to have a tool which allows me to write blog posts offline.  The WordPress editor is fine when you’re online, but sometimes I’ll be on an airplane or in a location without ready Internet access.  When I started researching blog editors, I landed on Windows Live Writer.  Although the product is in a dormant state, it’s still popular and for good reason.  It integrates with a number of services, gives you a pretty good idea of how your blog posts will look, lets you add images and links extremely easily (even easier than WordPress’s editor does), has seamless publishing, and lets you work offline.  It also lets you use one interface to publish against different blogs, although I only have this blog and so that benefit doesn’t do too much for me.

The biggest problem with Windows Live Writer is finding a working download link.  The Hanselman link above has it, but I also want to include the Windows Live Writer download link here.  I’ve confirmed that it works just fine with Windows 10.

I might look for something that works well with Android and Linux when I’m using tablets or laptops running those operating systems, but at least I have a workable product with my Windows tablet.

The Search For A Better Browser

Browsers and I have a long and somewhat-inimical relationship.  Here is what I want in a browser:

  1. Fast.  The browser should load faster than Netscape 4 did.  This means you, Firefox.
  2. Secure.  I want to turn off Javascript by default and turn it on when necessary.  Firefox has NoScript, which is great for that.  Chrome has historically tried to avoid adding that functionality, but ScriptSafe used to be a good alternative.  Ever since a couple of months ago, ScriptSafe has started to break Google searches, so I moved on to uMatrix (also available on Firefox).  I’ve liked that experience so far, especially because you can set domain-specific privileges, so I could allow third-party YouTube scripts on one domain but not another.
  3. Convenient.  Remember my settings, bring me back to where I left off in case I reboot my PC, and make it so that I don’t have to fight your UI.  Chrome is the worst about this:  by default, they don’t re-open tabs if you close the browser, meaning that you could lose a bunch of tabs if, say, Windows decides to reboot your computer overnight.

Every single browser on the market seems to fail me in various ways.  Here’s my current (and definitely not comprehensive) complaint list:

  • Edge:  I like how fast it is and how well it does HTML 5, but you cannot right-click and save!  Seriously, who let a modern browser out which does not allow you to choose to download things?
  • Internet Explorer:  Yeah, I’ve heard that IE 10 and 11 don’t suck nearly as much as IE used to, but you burned that bridge with me years ago, Microsoft.
  • Firefox:  NoScript is cool, but Firefox seems to get more and more bloated, slower and slower, more and more memory-intensive.  Just like Mozilla did.  Just like Netscape did.  It’s about time for another group to blow up the browser and start over; maybe it’ll be good for 2-3 versions like these other browsers were.
  • Chrome:  When I’m on a touchscreen device and I have a keyboard attached, I don’t want the on-screen keyboard to show up whenever I click on an input box.  I have a device which provides input already.  You should know that I have a device which provides input because Firefox and Edge don’t behave this way.  So what’s the advice Chrome gives?  Shut off on-screen keyboard…which is terrible advice for someone who has a tablet.  Also, Chrome has felt more bloated over time as well and it soaks up memory.
  • Safari:  I’ll admit that I don’t use Safari for Windows.  I tried it a few years back, but it was a horrible knock-off of the Apple version.  If I want a horrible knockoff browser, I’d reinstall Konqueror.
  • Opera:  Nope.

Are there any browsers on the market which don’t suck?  I’ll take Linux or Windows browsers.  Over on Android, I’m OK with Dolphin Browser because of its LastPass integration, tabbed browsing experience, and decent speed.

At Derbycon

Today marks the end of my Derbycon training.  This year, I ended up taking the basic Android hacking training.  I learned a good bit about the Android permissions model and we started to look into reverse engineering code from APK files.

Tomorrow will be the first day of talks.  Derbycon is a great conference, and one of the reasons it’s so great is that they pack in 10-12 hours of training each day.  Tomorrow starts at 8:30 AM and Irongeek will even be live streaming the opening sessions.  After that, sessions go on until 8 PM, and Saturday’s basically the same.