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:
- 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.
- 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.
- 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.
- 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.
- Run waagent -deprovision and halt the VM.
- 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.
- 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.
- Inside the Storage account, create a container and name it how you want. Get the full URL for your container.
- I’m assuming you already have a registered certificate with Azure. Use csupload to set the connection string.
- csupload set-connection “SubscriptionID=$STORAGE_SUB_ID; CertificateThumbprint=$CERT_THUMB; ServiceManagementEndpoint=https://management.core.windows.net”
- Make sure your certificate thumbprint is all caps, no spaces.
- Now use csupload to upload your VHD
- csupload Add-PersistentVMImage -Destination “$CONTAINER_URL/my.vhd” -Label “Debian Wheezy” -LiteralPath “C:UsersbureadoDesktopupload.vhd” -OS Linux
- csupload can resume partial uploads, so don’t worry. But I’ve uploaded 6 VHDs from 600 to 1500 MB with no hiccups.
- 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.