What is CDN?
CDN is basically a distributed storage system used to deliver content over the Internet to end users. CDNs serve a large amount of the content on the Internet today. The main goal of a CDN is make access to a wide range of file types like text, graphics and videos as quick as possible.
Lets get started!
If you’d like to manage your own CDN in Azure heres what you do. First you’re going to need an Azure account and I’m going to assume you already have that. Now lets move on to getting things setup. You’ll need basically two things, a storage account to get the origin domain and the CDN endpoint. Before you can create the CDN endpoint we have to have a storage account.
Create a storage account for an Azure subscription
- Log into the Azure Management Portal.
- 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.
- In the URL field, type a subdomain name. This must be a unique name.
- From the Region/Affinity Group drop-down list, select a region or affinity group for the storage account.
- From the Subscription drop-down list, select the subscription that the storage account will be used with.
- Click Create Storage Account. The process of creating the storage account might take several minutes to complete.
- Verify that the account appears in the items listed for Storage with a status of Online.
- Create a container call “**content**”. This is the default container in the blob location where files will be stored. Choose between “Private”, “Public Blob” and “Public Container”.
Private - No anonymous access and must provide azure storage account name and key
Public Blob - Anonymous access to individual file by url
Public Container - Anonymous access to the container using the REST API from the browser is allowed. So users could get a list of all the files in the container.
When your done you should end up with a URL similar to this. http://[mynewcdn].blob.core.windows.net/[content]
Create a new CDN endpoint for your storage account
- In the Azure Management Portal, in the navigation pane, click CDN.
- On the ribbon, click New. In the New dialog, select App Services, then CDN, then Quick Create.
- In the Origin Domain dropdown, select the storage account you created in the previous section from the list of your available storage accounts.
- Click the Create button to create the new endpoint.
- 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.
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:
Must Have Tools
Using azCopy to copy data to Azure CDN
There is currently no way to upload files from within the portal. azCopy provides a way to copy files into Azure storage without the need of a GUI or writing your own code.
- Download the latest [preview version](http://aka.ms/downloadazcopypr).
- Run the installation and accept all the defaults.
- Add the AzCopy installation location to your system path.
- Go to “System Properties” then click “Environment Variables”
- Edit the “Path” variable and append the path to “azCopy”.
- Open a command prompt the type “azcopy”. You should get help information for “azCopy”
Create azCopy Script
- Use the template script found here. ex: “azCopy /Source:**C:azureData** /Dest:**https://yourstorageaccount.blob.core.windows.net/content** /DestKey:**key** /S /XO”
- Add the <source> and <destination> for the CDN.
- Add the <destkey> for the CDN.
Using Azure Explorer
Azure explorer is a free graphical tool for managing Azure storage. So far it’s been the best free tool I’ve seen and it has a lot of capabilities. And since Microsoft does not let you upload data from the web portal you just about have to use this tool unless your a developer.
If you plan on using Azure storage this tool is a must have. Get it from http://www.cerebrata.com/products/azure-explorer/introduction.