Monday, 21 May 2012

Using the Azure CDN

A while back I toyed with the idea of moving all my blog assets (images, downloads, etc) over to a CDN just as a proof of concept and to show how it could be done and as a very handy way to get inspiration for a blog post. This evening I finally got around to it. And this post details how to do it.

So first a few basic things about the whole concept of a CDN.

What is a CDN?

A Content Delivery Network (CDN) according to Wikipedia is “a large distributed system of servers deployed in multiple data centres in the Internet. The goal of a CDN is to serve content to end users with high availability and high performance”. Its a large system of caching servers located around the world, speeding up the delivery of your content by reducing the distance between your users and your content and providing higher redundancy.

Why use a CDN?

One of the main reasons to use a CDN is more servers hosting your files, means higher availability meaning that if a node is down, the request will rollover to the nearest node after that.

Also it reduces the latency for your files when you have people accessing your site outside your hosting catchment for example, if your server is hosted in Dublin and a significant amount of your traffic comes from APAC. By using a CDN, your static resources that you have on your blog/site are cached in different locations around the world. When a user requests a file that is hosted on your CDN, the file is served where possible from the closest node in the CDN.

About the Azure CDN

The Windows Azure Content Delivery Network (CDN) caches Windows Azure blobs and the static content output of compute instances at strategically placed locations to provide maximum bandwidth for delivering content to users. You can enable CDN delivery for your content providers using the Windows Azure Platform Management Portal. CDN is an add-on feature to your subscription and has a separate billing plan.

Azure CDN nodes are located worldwide and you can get a list of them here

Setting up on the Azure CDN

This is one of the easiest things to do with Azure. As in absurdly easy. You will need an Azure account and you can sign up for a 90 day free trial at the Windows Azure Portal. You will need a credit card when you sign up to verify but you will not be charged and if you go over your free limit, it will just stop however you can allow it to run and charge to credit card if you so wish.

Once you have your account, sign into the management portal.

Now create a new storage account. This is where you will serve your static resources from. You do not need a hosted account to serve the files.

Type in the name and select the region for the storage and then once done wait for the storage to provision

Once the storage is ready, click on the CDN folder on the left of the management panel. You will see your newly created storage account. Click on the New Endpoint from the top menu and select the defaults.

The CDN endpoint will provision and you will eventually get a URL like XXXXXXX.vo.msecnd.net which is fine but most people want to have their own domain or subdomain on the CDN and this is very easy to do.

Click on the CDN endpoint and select Custom Domain from the top menu. You can insert the address that you want the CDN to resolve to. For example the one for this blog is assets.certsandprogs.com.

A verification CNAME will be created which points to verify.azure.com and you will need to create this CNAME in your domain management of your provider.

Once you have done this, go have a cup of tea or coffee because you will need the new CNAME to propagate and this could take a bit of time depending on your provider. For example, with GoDaddy, it took about 5 minutes but on a previous test, it took two hours on a different provider.

You can click validate to check and once its working you will see Allowed in the custom domain line.

The final thing you need to do now, is create a CNAME that points to your Azure CDN endpoint address. Once all this is done you will be able to use your brand new shiny CDN.

Getting files into the CDN for non programmers.

There are plenty of tutorials on how to get your data into blob storage so you can use your search engine of choice to find these. However, for the non programmers among you (why are you reading this blog?), there are a couple of programmes you can use to get your data into blob storage and onto your newly provisioned CDN

Azure Storage Explorer on Codeplex allows you to see your blob storage in a logical view as well as creating containers and upload objects to your containers.

So that’s about it, a fairly painless way to migrate to the cloud without needing any code.

All the images that in this post are being served from the CDN and I will migrating all the scripts used in the blog over to the CDN over the coming weeks. If I manage to create a nice little migration tool, I will share it on this blog.

4 comments:

Jalle said...

HI very interesting post you have here. I wonder if you Can maybe help me with my NET certification. I have passed 70 536, 70 562 and 70 480 exam and don't know which one to take next in order to get MCSD for Web developer.

Jalle said...

HI very interesting post you have here. I wonder if you Can maybe help me with my NET certification. I have passed 70 536, 70 562 and 70 480 exam and don't know which one to take next in order to get MCSD for Web developer.

Jalle said...

Lol since this comment was posted today with 2 monts delay,
I can say that you can remove it because in a mean time I become MCPD already ;-)

Unknown said...

Sorry about that.. it went into the spam folder and I didn't see it.. :( Well done on the MCPD!