Using Azure CDN to host your media

I recently had a dealing with a customer that wanted to host large amounts of media in one region in Azure, but they had multiple office sites all around the world….so they said “I know how to do it, let’s deploy multiple storage accounts in different regions so they can access the content faster in those locations”…that’s one way….one very long and tedious way of doing it because you’re gonna have to copy each media file to each storage account and so on….. I knew there had to be a more efficient dynamic approach to this, so I did some research and came across “Azure CDN”.

Wow what a great Resource, in layman’s terms, you can use Azure CDN to host media files and stream video content from all over the world without deploying multiple resources…So instantly this sounded great!

First let’s talk about Azure CDN, so CDN stands for “Content Delivery Network”, this resource is a hierarchy network of servers all over the world, utilizing this service in Azure you can publicly host and cache content such as images, video files, audio files, exe files, pdf files etc etc.
So this is great for hosting content which isn’t going to be changed on a regularly basis and which is going to be accessible from not just a single point (like if you used a standard Storage Account)

This will benefit any organization which wants to get content out faster without relying on a single end point in a specific region, and you have that complete flexibility for scaling the CDN application for content delivery.

Azure CDN has multiple nodes all over the globe which are referred to as Points of Presence (POP), this is what replicates you content onto “Edge” servers which are the actual physical servers themselves, so when you link your storage account to your CDN Profile, it will replicate your media or data to those Edge Servers all over the world utilizing those nodes.

Scenario: So there’s a bunch of Users that live in West US and they want to access the content hosted in the blob storage account which sits in West Europe, now  as soon as you upload your content to Blob Storage  when a user requests that content it will check to see if it’s already been accessed from the CDN Edge server, if not it will grab that content from the blob storage and start to replicate to the CDN and then cache it.
So the users in West Us won’t be hitting my domain, it will hit whatever endpoint you created setting this up, but with the domain which will be the closest Edge Server location to wherever the user resides.
The next time another user from West US comes to access the content, it will be a much lower latency and faster connection speed.

The below diagram will give you a better representation, visually of would happen when you deploy Azure CDN.

Setting up Azure CDN is an absolute doddle, first create a dedicated Storage Account in Azure, or use an existing one (It’s your choice) give your CDN Profile a name, select your Subscription & Resource Group and the location it resides in.

Now we get to the Pricing – which is on everybody’s mind when you’re utilizing Azure and someone else is paying the bill (they wana know how much your costing them)

Now you’ll notice that Azure CDN doesn’t use Microsoft’s own server infrastructure for hosting, it uses Verizon or Akamai (at the moment) – depending on which pricing plan you want, can determine which provider you wish to choose (info on the locations and more detail can be found here )

Be careful when selecting though, if you’re planning on using custom domains you’ll want to select which plan would be best suited for your business needs, so again be careful when selecting.

So I’ll be using the Standard Akamai Pricing, now I’ll need to create an endpoint for this.

The CDN Endpoint can be whatever name you like as it will direct the media content from blob storage to this
The Origin type is “Storage” If you’re actually utilizing blob storage for this, and the Origin hostname will be your domain linking to that storage account

Once you click “OK” that’s pretty much it, you’re ready to rock and roll, you can test this by hosting a simple image file within a blob storage container inside a folder (you can use Azure Storage Explorer app to upload huge chunks of media for ease and a more structured platform)

Testing: Picking one specific image to test, using a picture inside your blob storage url, you’ll have now if you change the beginning of the address too you’ll see it redirects to the exact same file, this is done automatically using Azure’s replication algorithm. So the user is going through the CDN Profile, to grab the image from blob storage account and caching it on the Edge Server …cool huh?

More Features:

You can allow and restrict access from different countries all over the globe using Geo Filtering, great solution for the upcoming GDPR situation.

Azure CDN also has full reporting facilities for deep dive analytics, real-time analytics for hourly bandwidth, hit ratio’s the lot, so it comes as an entire package.

And that my friends, is Azure CDN in a nutshell.