In Part 1 of this three-part series, I explained that it is simple and affordable to host an entire static website out of cloud storage services such as Amazon S3 and Windows Azure Blob Storage. I also covered what I meant by a static website (no PHP scripting), and I offered a few pointers in PHP-freeing a website, especially in the areas of mobile site redirection, contact forms, and moving a self-hosted WordPress Blog to WordPress.com. In Part 2, I showed how to get one’s feet wet with Amazon S3 and how to actually port a now-optimized website over to and host the entire website right out of Amazon S3.
In this entry, I would like to show how to basically do the same thing, this time using Windows Azure Blob Storage as the cloud hosting provider.
Before we get started, take a look at these blog entries from Paras Doshi and David Pallmann. These guys are more experienced with Windows Azure than I am, so they document the process very well (I’m basically following their instructions and documenting some interesting finds along the way). If you have questions about the process, these guys would be better to ask than I would since they’ve spent more time with Windows Azure than I have.
The first thing to do is register for a Windows Azure account. It’s free, easy to do, and takes only minutes to signup. Windows Azure offers a three month free trial, then afterwards, just like Amazon, you only pay for what you use.
Next, launch the Windows Azure Platform control panel and select the Hosted Services, Storage Accounts, and CDN pane from the sidebar.
Select the Storage Accounts link from the sidebar.
Once in Storage Accounts, select your Windows Azure subscription (in my case, 3-Month Free Trial) and select New Storage Account from the Windows Azure ribbon.
When the Create New Storage Account dialog box appears, enter something along the lines of mywebsite (or whatever your website name is, for the purposes of this tutorial, we’ll be using mallardcomputer), then select a region where you wish to host your website (for the purposes of this tutorial, we’re using South Central US for the hosting region).
Your storage account will now be created. Make use of the Blob URL on the right-hand sidebar (you will need this later). Next, select the storage account (in this case mallardcomputer) and select View Access Keys from the Windows Azure ribbon.
When the Storage Access Keys dialog box appears, copy down at least one of the access keys. You will need this later.
Next, we need a way to move our files to the Windows Azure Cloud. I highly recommend the free Cloudberry Explorer for those on Windows PC’s (and I’ll be using CloudBerry Explorer for the purposes of this tutorial). For Macs, CyberDuck is a good option.
Download and install CloudBerry Explorer, then bring up the Account Registration window from the File menu. Select New Account from the Account Registration window.
In the Add New Azure Blob Storage Account dialog, enter a Display Name (for my website I used Mallard Computer), an Account name (for my website, I used mallardcomputer), and enter one of the access keys in the Shared Keys section. Click OK.
Once the account is successfully created, we need to create a container in which to store or website objects (files). Click on the blue “Create New Container” button on the toolbar. Here I created a container called web.
In the Create New Container dialog box, give your container a name (in my case, I chose web) as well as choose an Access Control option (to ensure your website is public, choose Full Public Read Access).
Next, upload your files to your Windows Azure container. With CloudBerry Explorer, it’s as easy as using an FTP client or sending your files to an external hard drive.
Now you should be able to view your website at mywebsite.blob.core.windows.net/containername/index.html. For example, my website would be visible at mallardcomputer.blob.core.windows.net/web/index.html (however it’s not currently being hosted there since we’re using Amazon S3 instead). That’s obviously not a very good domain to be giving out to people on business cards and easy for people to understand. So the best thing to do is register a custom domain with a domain registrar and map the domain to the Windows Azure storage account. Go back to the Windows Azure Platform control panel and select the storage account (in my case mallardcomputer). Select Add Domain from the Windows Azure ribbon. Enter your domain with the www (so in my case, www.mallardcomputer.com). Click OK. Now, select the domain that appears and select Validate Domain from the Windows Azure ribbon.
When the Validate Custom Domain dialog box appears, copy the information in it. You will need it in just a moment.
Next, go to your domain registrar’s control panel and create a new CNAME record. Point what appeared in the top section of the Validate Custom Domain dialog box in the Windows Azure Platform control panel (the numbers and text gibberish followed by www.mydomain.com, in this case www.mallardcomputer.com) to verify.azure.com. It should look something like this (this is from GoDaddy’s admin panel).
Additionally, edit the www CNAME record to point to mywebsite.blob.core.windows.net (in my case mallardcomputer.blob.core.windows.net). This will allow Windows Azure to “host” the domain name so that typing in www.mywebsite.com/web/index.html (in my case www.mallardcomputer.com/web/index.html) will lead one to your website. But that’s still a little too long, especially having to type the www as well as all the additional stuff on the end. The solution? Turn on domain forwarding for mywebsite.com (in my case mallardcomputer.com) so that mywebsite.com points to www.mywebsite.com/web/index.html (in my case mallardcomputer.com would point to www.mallardcomputer.com/web/index.html). Therefore anyone typing in mallardcomputer.com would indeed go straight to my website without an issue, and anyone typing in mywebsite.com would indeed go straight to your website without an issue..
It’s simple and only takes an afternoon to host one’s static website entirely off of Windows Azure. Like Amazon S3, Windows Azure Blob Storage is a cost-effective and highly-scalable way to host static web files, even an entire static website, in the cloud. In the end, we chose Amazon S3 to host our static website, but Windows Azure also makes it easy to do so and is another great option for low-host, high-performance web hosting.