Using Azure CDN (Content Delivery Network) In Your App
The Windows Azure CDN is a convenient way for application developers to minimize latency that geographically dispersed application users will experience. As of as of February 2010, the Azure CDN is currently in CTP and incurring no charges.
Who Needs a CDN?
Application users that are geographically far away from the data center where a file they are attempting to access resides will experience a lag due to the distance the data has to travel to reach their client. CDN’s attempt to solve this issue by caching copies of the file in various geographic locations across the globe, the user attempting to access the file will be served from the nearest data center to minimize the latency. Latency is an especially acute problem for large files that are streamed to users (notably video files), but with the declining cost of CDN’s they are more and more commonly used to deliver smaller static files – the theme files for AzureSupport.com (such as the logo and css files) are all served via the Amazon CloudFront CDN.
Introducing the Windows Azure CDN
The Azure CDN features 18 edge locations (geographic points were the cached data is served from) for blobs which are in public containers.
Using The Azure CDN
The Windows Azure CDN is tightly integrated into Azure Storage, to enable it simply navigate to the appropriate storage account in the Azure developer portal and click Enable CDN, this will turn on the CDN for that storage account although there may be a delay of up to 60 minutes before it is available for use.
Once the CDN is functioning the only change will be the URL from which your blobs are accessible, the URL will be in the following format – http://<guid>.vo.msecnd.net/<container name>/.
TTL – Time to Live
One issue you will have to contend with is the caching of the blobs. If you need to update the blob (ie replace the file with an updated version) the new version will not be accessable by users until the cache has expired and the Azure CDN refreshes the cache from the actual blob in the storage container. The expiry time for the cache is know as the TTL (Time To Live). The default for Azure is 72 hours, however this can be manually adjusted by setting the CloudBlob.Attributes.Properties.CacheControl property of the CloudBlob object in your code. It should be noted that setting the TTL to a short time will reduce the effectiveness of the CDN as the CDN will only reduce the request time when the blob is cached at an edge location.
It should be noted that blobs which are deleted will still be available at any edge location it is cached at until the TTL expires.
Registering a Custom Domain for Azure CDN
If the default URL does not appeal, you can register a custom domain as the CDN URL for that storage account (note that only one custom domain can be registered per CDN endpoint). To register a custom domain, navigate to your storage account, if it has the Azure CDN enabled it will have a URL in the format http://<guid>.vo.msecnd.net/ listed under Custom Domains. Click ‘Manage’ to the right of this URL. On the Custom Domain for CDN Endpoint page, enter the custom domain and click Generate Key. The next page will show a CNAME record which you will have to enter for the domain and then Validate to ensure you are the domain’s admin or owner.
Once the domain’s ownership has been validated you can create a CNAME record for your chosen domain and then point that to your default Azure CDN URL, this will then allow you to use your custom domain for all URL’s.



02. Feb, 2010 








Trackbacks/Pingbacks
[...] your application as shown in the Deploying the App on Azure tutorial. You can also enable the Azure CDN for your [...]