Hosting a Simple Website in the Windows Azure CDN

Slalom Consultant Joel Forman

Slalom Consultant Joel Forman specializes in cloud computing and the Windows Azure Platform.

With the update of the Windows Azure SDK a few weeks ago came a few changes to the Windows Azure Content Delivery Network.  The Windows Azure CDN can help improve end-user performance by placing content closer to the user, at different points around the globe.  Prior to the 1.4 release of the Windows Azure SDK, the only type of content that was available through the CDN was BLOBs stored in Windows Azure BLOB Storage.  With this latest update, you can now cache content from hosted services, with support for query strings.  For more information about this, visit MSDN.

These enhancements to the CDN will enable some more interesting scenarios on how it can be leveraged.  Steve Marx already posted about it in this post.

One thought I had was around hosting an entire simple website from the CDN, meaning that all content requested by the end-user would be delivered via the CDN.  I was working on a project recently that had a need for this type of scenario (simple content with very high scalability and performance needs).  BLOB storage doesn’t quite support the scenario today, mainly due to the fact that containers don’t have default blobs, so a request to a container doesn’t really mimic a request to the root of a web site or folder.  But the capability of creating a CDN endpoint to hosted service content just might.

Before I dive into a sample, here are a couple of key points about using the CDN with hosted services.

  • Create a “cdn” folder at the root of your site.
  • After deploying, add a new CDN endpoint for your hosted service in the Azure Management Portal, which maps to the “cdn” folder.

I created a new Windows Azure Project in Visual Studio with no roles.  I then added a new role to the project because a wanted to select the “ASP.NET Empty Web Application” project type, so I get something really bare bones.  I then created that “cdn” folder, and that is where I started to put some simple content.  I made a couple of pages, a style sheet, and an images folder for images.  Again, for this sample I was sticking to something simple conceptually.

As I created some sample content, I made sure that I used relative URLs for referencing files.  This is key because I want to make sure that all requests from a client will go through the CDN.

After publishing and deploying via the Azure Management Portal, my sample site was ready.  I then enabled the CDN and added a new endpoint for my hosted service, which again maps the designated CDN URL to the “cdn” folder.  When the endpoint was ready, I hit the default CDN URL generated for my endpoint in a browser.  I was pleased to see the “index.htm” page returned via the CDN.  I got the behavior of a web server through the CDN.

I took a peek in Firebug to verify that all the content was coming through the CDN.

This is a simple sample, but it illustrates a powerful capability.  If I had the need for a simple site (think marketing site) to scale to a large global audience and wanted to ensure great performance, this solution would work.  Furthermore, since the content is being cached in the CDN, I could keep the number of instances of my web role low because it is not absorbing much traffic (only when a CDN node’s content needs to be refreshed).  I actually used an extra small instance for this demo.

I didn’t take it as far as adding a custom domain name to my CDN endpoint, but that can be easily done.  Also, I did not address setting cache control headers in this sample.  For a real world implementation, knowing how long your content would be cached would be important.

I am sure there are a lot of other interesting use cases, especially around caching specific content with query strings.  I’m looking forward to seeing other great examples out there.

– Joel

Follow Joel on Twitter: @seattlejoel.

Slalom Consulting's Seattle Office Slalom Consulting Cloud
More about Slalom Consulting’s Seattle office. More about Slalom Consulting’s Cloud focus.

subscribe by emailSubscribe to be emailed about new Cloud posts.

About Joel Forman
Joel Forman is a Solution Architect at Slalom Consulting and specializes in cloud computing and the Windows Azure Platform.

2 Responses to Hosting a Simple Website in the Windows Azure CDN

  1. Pingback: Hosting a Silverlight Application Through the Windows Azure CDN « The Slalom Blog

  2. Hosting says:

    HI,

    I have tried several times with the update of Windows Azure Content Delivery Network. But I failed every time. I was trying to find some help tips about this. Thanks for your illustrative method.

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

%d bloggers like this: