I attended a Microsoft dev camp yesterday where I learned some more about Azure and what you can use it for in your corporation. The material was presented by David Washington (@dwcares), a Microsoft Technical Evangelist here in the Twin Cities.
When I signed up for the session, titled "Sharpening your skills on the Microsoft Modern Platform", I was hoping for a more developer-centric session but it turned out to be geared more toward IT pro/infrastructure. Nonetheless there was one thing that David kind of glossed over that immediately got my wheels spinning.
When you go to create a new Virtual Machine in Azure, there’s a "From Gallery" option. While David was highlighting the wide array of already-available environments (SUSE, Oracle, Windows Server), I noticed:
Wait a minute… a Visual Studio Virtual Machine? I asked about this and found out that it’s a Windows Server 2012 instance with VS 2013 RC pre-installed.
Let’s think about this for a minute… Create a virtual machine that has Visual Studio on it. After I do this, I have the capability to:
That’s right. I can RDP in to a Windows Server 2012 machine running Visual Studio 2013. What does this mean? Well, let’s go one step further and sign up for a free Team Foundation Service account since I’m an individual developer and this is free for teams up to 5. Now I have a source repository for all my code in TFS, and a VM running VS 2013 that I can remote in to.
My dev machine crashes. Gets run over. Gets snapped in half by the 3 year old.
Ha, you can’t stop me! I remote right in to the server and continue my development from another machine.
What’s more, check it out. You can create your own VHDs and upload them to Azure then run them as virtual machines.
So let’s think through this… We have tools that can create VHD files from the system they’re running within (Disk2Vhd) and we have Azure with the capability to run an externally-created VHD.
Folks, you could theoretically create a VHD for your current machine, upload it to Azure, and run it on a 8 core 56GB RAM A7 Server instance (or a smaller one, if you’re a wimp).
So guess what we’re going to be doing?
- Azure account (sign up for a free 90-day trial if you don’t have one already)
- Windows 8/8.1 Pro ISO (to install on VHD of machine to upload)
- Windows 8/8.1 License key (current one you’re using is fine, it’s just to complete the install)
- Visual Studio install
Got all your ducks lined up? Let’s knock ‘em down!
Step 1 – Create the Hyper-V machine
Go to the start screen, type ‘Hyper’ and you should see the following show up:
You want that first one, the Hyper-V manager.
Create a new Hyper-V machine by selecting all the default options until you get to the ‘Installation Options’ part. At this point, we’ve got to point the installation media to the ISO of our Windows installer:
That’ll make it fire this up when it boots, so we can install Windows. If you followed these steps the ‘Summary’ screen should look like this:
Now we just fire up the VM like so:
You now the drill from here on out, get Windows installed and come back when you’re ready to move on. Make sure that BEFORE you go to step 2 you set up the user account you created (and the machine in general) for remote access.
Step 2 – Prep the system for Azure
When you deploy a VHD to Azure, obviously you can’t just take your whole license key and all that stuff – you’ve gotta clean it up. To do this, it’s as easy as using the built-in “sysprep” tool.
Fire up a command line & run sysprep:
Execute it as follows:
Step 3 – Convert to VHD
Azure doesn’t support VHDX. If you created your Hyper-V machine on Windows 8, you might be ok (just check the extension of the file that got created in the ‘Summary’ screen above). If you’re on 8.1, you don’t get the option – it creates VHDX by default.
No matter, there’s a PowerShell script for that.
Fire up Powershell and run:
> convert-VHD –path <vhdx>–destinationpath
> convert-VHD –path “C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\New Virtual Machine.vhdx” –destinationPath c:\users\brandon\desktop\azure.vhd –vhdtype dynamic
it’ll crank for a bit and then *poof* the file you specified for –destinationPath will appear.
Step 4 – Do what this says
Instead of reinventing the wheel, the rest of the stuff you need to do can be found here. You can skip to step 2 as I covered Step 1 of those instructions in my Step 2. Enjoy!
Step 5 – Create an Azure VM targeting your newly-uploaded VHD
After completing the steps on that page, you can now create the VM that’ll load your new Image. Head to the Virtual Machines area of your Azure Management Portal and click ‘New’ and ‘From Gallery’
When the gallery popup appears, choose ‘My Images’ and pick the Image that you just created from the VHD:
Carry on through the rest of the VM setup and eagerly await the ‘Provisioning…’ and ‘Starting…’ steps!
If you want to learn more cool Microsoft stuff, the Microsoft Virtual Academy is a great place to start.