Skip to main content

Using CDN for Azure

The Azure Content Delivery Network (CDN) offers developers a global solution for delivering high-bandwidth content by caching blobs and static content of compute instances at physical nodes in the United States, Europe, Asia, Australia and South America. For a current list of CDN node locations, see Azure CDN Node Locations.
This task includes the following steps:
  • Step 1: Create a storage account
  • Step 2: Create a new CDN endpoint for your storage account
  • Step 3: Access your CDN content
  • Step 4: Remove your CDN content
The benefits of using CDN to cache Azure data include:
  • Better performance and user experience for end users who are far from a content source, and are using applications where many 'internet trips' are required to load content
  • Large distributed scale to better handle instantaneous high load, say, at the start of an event such as a product launch
Existing CDN customers can now use the Azure CDN in the Azure Management Portal. The CDN is an add-on feature to your subscription and has a separate billing plan.

Step 1: Create a storage account

Use the following procedure to create a new storage account for a Azure subscription. A storage account gives access to Azure storage services. The storage account represents the highest level of the namespace for accessing each of the Azure storage service components: Blob services, Queue services, and Table services. For more information about the Azure storage services, see Using the Azure Storage Services.
To create a storage account, you must be either the service administrator or a co-administrator for the associated subscription.
To create a storage account for an Azure subscription
  1. Log into the Azure Management Portal.
  2. In the lower left corner, click New. In the New Dialog, select Data Services, then click Storage, then Quick Create.
    The Create Storage Account dialog appears.
    Create Storage Account
  3. In the URL field, type a subdomain name. This entry can contain from 3-24 lowercase letters and numbers.
    This value becomes the host name within the URI that is used to address Blob, Queue, or Table resources for the subscription. To address a container resource in the Blob service, you would use a URI in the following format, where <StorageAccountLabel> refers to the value you typed in Enter a URL:
    http://<StorageAcountLabel>.blob.core.windows.net/<mycontainer>
    Important: The URL label forms the subdomain of the storage account URI and must be unique among all hosted services in Azure.
    This value is also used as the name of this storage account in the portal, or when accessing this account programmatically.
  4. From the Region/Affinity Group drop-down list, select a region or affinity group for the storage account. Select an affinity group instead of a region if you want your storage services to be in the same data center with other Windows Azure services that you are using. This can improve performance, and no charges are incurred for egress.
    Note: To create an affinity group, open the Settings area of the Management Portal, click Affinity Groups, and then click either Add an affinity groupor Add. You can also create and manage affinity groups using the Windows Azure Service Management API. For more information, see [Operations on Affinity Groups].
  5. From the Subscription drop-down list, select the subscription that the storage account will be used with.
  6. Click Create Storage Account. The process of creating the storage account might take several minutes to complete.
  7. To verify that the storage account was created successfully, verify that the account appears in the items listed for Storage with a status of Online.

Step 2: Create a new CDN endpoint for your storage account

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.
To create a new CDN endpoint for your storage account
  1. In the Azure Management Portal, in the navigation pane, click CDN.
  2. On the ribbon, click New. In the New dialog, select App Services, then CDN, then Quick Create.
  3. In the Origin Domain dropdown, select the storage account you created in the previous section from the list of your available storage accounts.
  4. Click the Create button to create the new endpoint.
  5. Once the endpoint is created, it appears in a list of endpoints for the subscription. The list view shows the URL to use to access cached content, as well as the origin domain.
    The origin domain is the location from which the CDN caches content. The origin domain can be either a storage account or a cloud service; a storage account is used for the purposes of this example. Storage content is cached to edge servers according either to a cache-control setting that you specify, or to the default heuristics of the caching network. See How to Manage Expiration of Blob Content for more information.

Step 3: Access CDN 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>.vo.msecnd.net/<myPublicContainer>/<BlobName>

Step 4: Remove content from the CDN

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.
An object already cached in the CDN will remain cached until the time-to-live period for the object expires. When the time-to-live period expires, the CDN will check to see whether the CDN endpoint is still valid and the object still anonymously accessible. If it is not, then the object will no longer be cached.
The ability to immediately purge content is currently not supported on Azure Management Portal. Please contact Azure support if you need to immediately purge content.

Additional resources

Comments

Popular posts from this blog

Accessing File Stored in Windows Azure Blob Storage Using jQuery

Did you know it was possible to access the Windows Azure Blob Storage directly from JavaScript, for example using jQuery? At first, it sounds obvious, since Blobs are after all accessible from a public UR. But in practice, there is a very big hurdle: the Web browser’s Same Origine Policy or SOP, that restricts JavaScript code to accessing resources originating from the same site the script was loaded from. This means that you will never be able to load a Windows Azure Blob using XMLHttpRequest for example! Fortunately, there is a popular workaround called JSONP (“JSON with Padding”). The idea behind this technique is that the script tag is not submitted to the SOP: an HTML page can thus load a JavaScript file from any site. So, if you expose your data in an “executable” form in JavaScript, a page will be able to load this data using a script tag. For example: <script type=”text/javascript” src=”http://www.sandeepknarware.in/exemple.jsonp”> </script> But how can ...

gcAllowVeryLargeObjects Element

There are numerous new features coming with .NET 4.5 and here, on this blog, you can find several posts about it. But the feature we are goint to talk about today is very exciting, because we were waiting for it more than 10 years. Since .NET 1.0 the memory limit of .NET object is 2GB. This means you cannot for example create array which contains elements with more than 2GB in total. If try to create such array, you will get the OutOfMemoryException. Let’s see an example how to produce OutOfMemoryException. Before that Open Visual Studio 2012, and create C# Console Application, like picture below. First lets create simple struct with two double members like example below: 1 2 3 4 5 6 7 8 9 10 11 12 public struct ComplexNumber {      public double Re;      public double Im;      public ComplexNumber( double re, double im)      {    ...

Support for debugging lambda expressions with Visual Studio 2015

Anyone who uses LINQ (or lambdas in general) and the debugger will quickly discover the dreaded message “Expression cannot contain lambda expressions”. Lack of lambda support has been a limitation of the Visual Studio Debugger ever since Lambdas were added to C# and Visual Basic.  With visual studio 2015 Microsoft has added support for debugging lambda expressions. Let’s first look at an example, and then I’ll walk you through current limitations. Example To try this yourself, create a new C# Console app with this code: using System.Diagnostics; using System.Linq; class Program { static void Main() { float[] values = Enumerable.Range(0, 100).Select(i => (float)i / 10).ToArray(); Debugger.Break(); } } Then compile, start debugging, and add “values.Where(v => (int)v == 3).ToArray()” in the Watch window. You’ll be happy to see the same as what the screenshot above shows you. I am using Visual Studio 2015 Preview and it has some limitati...