Debian Wheezy and Windows Azure

(Looking for a way to do this only using Linux (i.e., not using csupload)? Pierre Couzy, a peer at Microsoft, has some notes)

Nowadays, it’s no longer a secret that Azure has support for a lot of open source tools I’ve been using for the past decade. While IaaS it’s not the most interesting feature (I truly think lots of people are abusing of IaaS with VPS and the like when they could be achieving economies of scale with PaaS — and Azure has both Web Sites and Worker Roles for that…) it’s certainly one of the most discussed about.

The Debian Project founded the debian-cloud mailing list, and Windows Azure has been a recurring topic there as well.

The VM Feature offers customers the ability to fire a VM from a gallery which has preset images (VHDs) for Windows Server but also for SuSe, CentOS and Ubuntu. But not Debian. However, they also offer the ability to upload your own VHD. So here’s my process to setup, upload and fire a Debian VHD:

  1. Download the latest wheezy netinst CD for amd64. Azure takes 64 bits OS. wheezy’s d-i already has a mode Linux which has the Hyper-V drivers on mainline and in place.
  2. Fire a VM on Hyper-V. I’m using Hyper-V on Windows 8 Pro, but you could use a Server version if you want. Hyper-V is a free as in free beer product for a Windows customer.
  3. Go thru the Debian Installer, with no specific suggestions for the Azure case. I used LVM, no DHCP (though I’ve set this up later) and that’s about it.
  4. Once inside your installed OS, install the waagent package. You can get that from Hupstream’s repo. The package has an ITP and it’s been reviewed, so hopefully it will get into the archive soon. waagent requires OpenSSL, OpenSSH and sudo, so make sure you also have connectivity to get that.
  5. Run waagent -deprovision and halt the VM.
  6. Now, in Hyper-V, export the VM in VHD format. Make sure you use VHD, and not VHDX (Windows 8, and I guess Server 2012, will prefer VHDX) and to export it in the Dynamic format. I got an image of about 700 MB which was real nice.
  7. On the Windows Azure Management Portal, create a new Storage account using Quick Create, name it how you like and make sure you attach it to the affinity group (geographic region) you want your setup to run. Get the Subscription ID (large string) for your Storage account.
  8. Inside the Storage account, create a container and name it how you want. Get the full URL for your container.
  9. I’m assuming you already have a registered certificate with Azure. Use csupload to set the connection string.
    1. csupload set-connection “SubscriptionID=$STORAGE_SUB_ID; CertificateThumbprint=$CERT_THUMB; ServiceManagementEndpoint=https://management.core.windows.net”
    2. Make sure your certificate thumbprint is all caps, no spaces.
  10. Now use csupload to upload your VHD
    1. csupload Add-PersistentVMImage -Destination “$CONTAINER_URL/my.vhd” -Label “Debian Wheezy” -LiteralPath “C:UsersbureadoDesktopupload.vhd” -OS Linux
    2. csupload can resume partial uploads, so don’t worry. But I’ve uploaded 6 VHDs from 600 to 1500 MB with no hiccups.
  11. Create a new VM from the Gallery, choose “My images” and pick the one you uploaded. Fill out the rest of the fields, wait for it to be provisioned and start it. You’ll have it up in seconds. Go ahead and ssh into it with the useame/password you specified.

Now you’re running sweet, sweet Debian in Microsoft’s cloud. The scenario proves useful if you’re running a .NET, PHP or any other app that runs on Azure Web Sites and need to connect to a service that is not offered as SaaS (Mongo or MySQL are, but Postgres is not) or a client/server or very specific webservice you can’t run on Azure Web Sites or as a Worker Role. If it’s on the same affinity group (region) as your website, performance will be real fast.

I showcased this with a large PHP application for DMS/Workflow connecting to PostgreSQL (Spanish ahead) that I could run in Ubuntu using Azure’s Gallery… but I had to do it on Debian!

Enjoy your hacking.
About these ads

Posted on December 15, 2012, in Uncategorized. Bookmark the permalink. 2 Comments.

  1. Yonel Meza Avila

    To avoid any network trouble, maybe you could add delete /etc/udev/rules.d/70-persistent-net.rules before halt the VM

  2. Thanks for this really useful guide.Note that Microsoft Open Technologies provide VM Depot a community managed repository of open source virtual machines. These images can be easily deployed to Azure from the command line. VM Depot includes a Debian image (Wheezy). It would be great to see more images using Debian as their base OS.

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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,929 other followers

%d bloggers like this: