다음을 통해 공유


Global Delivery with Azure CDN (Content Delivery Networks) Step-by-Step ………

 

By Blain Barton

Content Delivery Networks (CDNs) connect the world together, streaming video, images and websites delivering amazing content to our devices and TV. I don’t have the patience to watch spinney going around in circles waiting for something to show up on the screen, watch a choppy movie or sit and wait for a web part to load. When I watch a pay-per-view movie sitting in Tampa Florida do you think it is streaming from Silicon Valley? Well most likely it’s coming from a CDN in Miami or closer. There are thousands of CDN’s ranging from ones like Miami’s Level3 who provides local-to-global connectivity to Microsoft Azure CDN which provides end-to-end high performance and networking power  Let’s take a closer look at Microsoft Azure’s CDN when dealing with streaming media in particular. Once you get this setup you can use it for lots of other services. Most importantly your content will be available closer to your customers. If you have a website that is rich with video, forms and plug-ins that sits in London but most of your customers are in Charlotte North Carolina you might want to consider setting up a CDN in the East US, most likely located in Atlanta.

The benefits of using CDN to cache Azure data provides optimal performance and a better user experience for end users who are far from the content source. Take for example, applications being used where many 'internet trips' or “hops” are required to load content that is being distributed. CDN handles the large distribution at scale and high loads meeting the demand our customers expect.

Microsoft currently has 31 point-to-presence (POP) CDN locations and offers developers a global solution for delivering high-bandwidth content that's hosted in Azure. Providing the content your customer needs, when they need it.The CDN caches publicly available objects such as videos and websites at strategically placed locations to provide maximum bandwidth for delivering content to end users and customers. I posted the map that show the current locations.

locations

To get started you want to login to the Microsoft Azure Portal and first create a “friendly” storage account.   This is where your content is going to be located and propagated to the CDN endpoint when you create. For instance, if you’re sitting in London and want to have your media or website be readily available for customers in Charlotte you would chose East US.

1. First create a friendly storage account, I always use the same naming conventions when creating my storage accounts. I use xxcdnsa01 where the xx is your initials, the CDN is your CDN, sa for storage account and 01 for first account created. It would look like xxcdnsa01. The reason I do this is because when you create a Virtual Machine or Media Service directly from the GALLERY it needs to have a storage account to put the .VHD and .WMV files in. If you don’t have a storage account created for these services it creates them for you. Well not an ideal situation if you build a lot of virtual machines and then find out you can’t change the storage account names. Every time it asks you for the storage account name there will be some pyxddre34dmessedup name and this becomes hard to manage down the road when using tools like PowerShell. It’s also a good best practice to write down your naming conventions.

My friendly storage account for the CDN will be bbcdnsa01 and since I’m now in London I’ll create it in the East US region. You would pick the region that you want to cache the media using a CDN Endpoint. Pick your subscription and leave on Geo-Redundant.  Create the storage account.

Next, create your CDN endpoint, this is where the media files or website files are cached from your newly created storage account.  It will create a CDN Endpoint automatically.

https://az741314.vo.msecnd.net/ Note – You will get a HTTP 400 Bad Request, this is normal as it is propagating to the CDN.

You can see below that it shows the general information such as the name of your CDN, the CDN Endpoint, Endpoint Status, Protocol Enabled and Query String Status.  None of these setting need to be changed except ENABLED HTTPS.

You can also add your own custom domain to the CDN endpoint, This will be covered in a different article that goes more into detail. For now we will stick with the simplified method.

After the CDN Endpoint is created it’s time to go get Azure Storage Explorer you need to upload your media files up into the storage public container.

Go back to Storage account and create a container. Remember your naming conventions?  My example is bbcdn01pub, for public container, as you can make these public or private. We want a public container for this so all users can access it.

With the container now created. The next step is to use Azure Storage Explorer (located you can but the area) to view the storage account. Once completed, the creation of the blob is our next step and then we can upload the .WMV I will be using for this example.

On the Storage account page, go to Get the tools and select Storage Explorers,

There are various tools to use, some are free and some you pay for. For this example I’ll be using Azure Storage Explorer.

Go to downloads

Click on the .ZIP file below and install the program,

Note: Read the license Agreement Terms as Microsoft nor myself are liable for any problems you may have on your machine.

Go back to your storage account and go down to MANAGE ACCESS KEYS

You’re going to want to select the PRIMARY ACCESS KEY as you will use this in the Azure Storage Explorer to connect to the storage account.

In Azure Storage Explorer, go to Add Account, select Cloud Storage Account, UNLESS you have visual Studio and are using a Local Developer Account. You then put the Storage account name (make sure this is correct), Storage account key (PRIMARY ACCESS KEY in Azure), Microsoft Azure Default, use HTTPS (blobs are using https://)and Test Access.   You see that it generated an “Account access successful”. If you do not have success, reverse engineer it. It’s usually a typo for me.

Add Account and you will see your Blob Containers with the public container I created in Azure which was bbcdn01pub.

Click on Security and then make sure that the Public Container Is selected.

Select Public Container as this gives Anonymous clients read blob and container content/metadata. Make sure and select Update Access Level.

You can now upload a .WMV file that you want to use as an example.

In my example, I am using the Windows Datacenter Video. Open and upload the file.

Return back to the Azure Portal and navigate back to the CDN service. There you will find the link you can use to test your newly created CDN service.

Open your browser and paste the link in that you just copied from your CDN service. It may prompt to Open and Save, or stream from the start, depends on your browser settings.

To see your CDN Endpoint in action, I make it clear that you will use the CDN Endpoint followed by your public container and then the filename as listed in the storage URI. Everything that is in storage will be cached at the CDN Endpoint as well.

https://az741314.vo.msecnd.net/bbcdn01pub/Microsoft%20Datacenter%20Video.mp4

Below is the link to the CDN Endpoint. You can tell as it is a .vo.msecnd.net domain. You can however choose your own custom domain name as well. You can also embed this as code on web pages and blogs streaming content that is now closer to your customers. See how easy it is to deliver content using Azure CDN to your customers?

As you start to get this built there many other things you can do in the blob properties and metadata including Cache Control, Content Encoding, Content Language, Content MD5 and other metadata information.

For more information on Azure CDN, click on the banner below to get started.

Blain Barton
Senior Technical Evangelist
US Developer Experience and Evangelism - DX Team
East Region – Florida
Microsoft Corporation

Meetup https://www.meetup.com/Florida-IT-Professionals

Blog - https://aka.ms/blainbarton

Early Experts - https://aka.ms/itproexpert

Microsoft Azure - https://aka.ms/try-azure

BizSpark Champ - BizSpark Program https://aka.ms/go-bizspark

Twitter @blainbar

Facebook and LinkedIn – Blain Barton