Click here to Skip to main content
11,484,941 members (72,452 online)
Click here to Skip to main content

Tagged as

Dev for the cloud… IN the cloud

, 14 Nov 2013 CPOL 3.4K 5
Rate this:
Please Sign up or sign in to vote.
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.

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:

image_thumb1_thumb1

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:

image_thumb3_thumb1

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?

Prerequisites:

  1. Azure account (sign up for a free 90-day trial if you don’t have one already)
  2. Windows 8/8.1 Pro ISO (to install on VHD of machine to upload)
  3. Windows 8/8.1 License key (current one you’re using is fine, it’s just to complete the install)
  4. 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:

image_thumb4_thumb1

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:

image_thumb7_thumb1

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:

image_thumb9_thumb1

Now we just fire up the VM like so:

image_thumb12_thumb1 image_thumb11_thumb1

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:

image_thumb16_thumb1

Execute it as follows:

image_thumb18_thumb1

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 –destinationpath –vhdtype dynamic

eg:

> 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.

image_thumb14_thumb2

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:

image_thumb20_thumb1

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

BC3Tech
Software Developer (Senior)
United States United States
No Biography provided
Follow on   Twitter   Google+

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150520.1 | Last Updated 14 Nov 2013
Article Copyright 2013 by BC3Tech
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid