CloudDays™ – Introduction to Azure Content Delivery Network (CDN)

cdnAzure Content Delivery Network (CDN) is designed to send audio, video, applications, images, and other files faster and more reliably to customers using servers that are closest to each user.  If you want to put binary files and blobs closer to your user, then CDN can be the right solution.

The CDN caches publicly available objects at strategically placed locations to provide maximum bandwidth for delivering content to users.

Essentially, when a user wants some content, the first user gets the data from the source server. When you use a CDN, that data is then cached at a site near the user. So subsequent users can get the data from the cache instead of going all the way back to the source server. For example, if a picture stored in a blob is in a European data center in Azure, a user in Portland Oregon would be able to access the file from a server set up in Seattle, making your image load much faster.

Use Cases

You may have an object or blog that is accessed frequently a specific their time-to-live (TTL) period. You can set the TTL in Azure CDN – the default is seven days. Good candidates are static content such as images, JavaScript code, and style sheets.

A CDN is ideal for Web content (static or otherwise) experiencing a surge in traffic because distributed CDN servers can handle a sudden large number of client requests at one time over the Internet. For example, spikes in Internet traffic from flash crowds due to a popular event, such as an online streaming video of a presidential inauguration, can be spread out across the CDN, making content delivery faster and less likely to fail.


CDN management software dynamically calculates which server is located nearest to the requesting client and delivers content based on those calculations. This not only eliminates the distance that content travels, but also reduces the number of hops a data packet must make. The result is less packet loss, optimized bandwidth and faster performance which minimizes time-outs, latency and jitter, while improving overall user experience (UX). In the event of an Internet attack or malfunction at a junction of the Internet, content that’s hosted on a CDN server will remain available to at least some users.

Craig Buckler describes seven reasons to use a content delivery network:

  • Different domains. Because the CDN is hosted on a different domain, a single CDN permits the browser to download a further four files at the same time.
  • Files may be pre-cached. For example, if you use a CDN to host jQuery, it has already been cached by your browser and won’t need to be downloaded again.
  • High-capacity infrastructures.
  • Distributed data centers. Many CDNs provide localized data centers which are closer to the user and result in faster downloads.
  • Built-in version control.
  • Usage analytics.
  • Boosts performance and saves money.

Setting up your Azure CDN

The Azure documentation provides a good tutorial at Using CDN for Azure. And so here is a quick summary.

Set up storage account

First, you will set up your storage account. So you will have a URL in this format.


Set up CDN endpoint

Once you enable CDN access to a storage account or hosted service, all publicly available objects are eligible for CDN edge caching. If you modify an object that is currently cached in the CDN, the new content will not be available via the CDN until the CDN refreshes its content when the cached content time-to-live period expires.

Next, create a new CDN endpoint for your storage account.

  1. Log into the Azure Management Portal.
  2. In the navigation pane, click CDN.
  3. On the ribbon, click New. In the New dialog, select App Services, then CDN, then Quick Create.
  4. In the Origin Domain dropdown, select a storage account from the list of your available storage accounts, or select a cloud service from the list of your available cloud services.
  5. Click the Create button to create the new endpoint.

You can also Map Content Delivery Network (CDN) Content to a Custom Domain.

Access content

To access cached content on the CDN, use the CDN URL provided in the portal. The address for a cached blob will be similar to the following: http://<CDNNamespace><myPublicContainer>/<BlobName>

Remove Content

If you no longer wish to cache an object in the Azure Content Delivery Network (CDN), you can take one of the following steps:

  • For an Azure blob, you can delete the blob from the public container.
  • You can make the container private instead of public. See Restrict Access to Containers and Blobs for more information.
  • You can disable or delete the CDN endpoint using the Management Portal.
  • You can modify your hosted service to no longer respond to requests for the object.

Best Practices on Setting TTL

Manage the expiration of Blog Content

Any content that you wish to cache via the CDN must be stored in your Azure storage account as a publicly accessible blob. For more details on the Azure Blob service, see Blob Service Concepts.

You have two options for controlling the TTL.

  1. Do not set cache values thus using the default TTL of 7 days.
  2. Explicitly set the x-ms-blob-cache-control property on a Put Blob, Put Block List, or Set Blob Properties request, or use the Azure Managed Library to set the BlobProperties.CacheControl property. Setting this property sets the value of the Cache-Control header for the blob. The value of the header or property should specify the appropriate value in seconds. For example, to set the maximum caching period to one year, you can specify the request header as x-ms-blob-cache-control: public, max-age=31556926. For details on setting caching headers, see the HTTP/1.1 specification.

For a code example, see  How to Manage Expiration of Blob Content in the Azure Content Delivery Network (CDN).

Manage Expiration of Cloud Service Content

You can control the update frequency by including a web.config in the CDN folder containing the content and modifying the clientCache settings to control the Cache-Control header for your content.

Or you can programmatically cache application content.

For a code example, see How to Manage Expiration of Cloud Service Content in the Azure Content Delivery Network (CDN).

More Best Practices

See Best Practices for the Windows Azure Content Delivery Network

Azure CDN Billing

The CDN billing region is based on the location of the source server delivering the content to the end user. The destination (physical location) of the client is not considered the billing region.

For example, if a user located in Mexico issues a request and this request is serviced by a server located in a US point of presence (for example Los Angeles) due to peering or traffic conditions, the billing region will be US.

Other CDNs

You might be interested in other CDN services:

You can find a comprehensive list on Wikipedia page Content delivery network.