In all the previous exercises, we've been working with the storage account that's created and managed in the Southeast Asia region in Azure. Serving all the images and streaming video content from a particular region will give the best experience for the people in and around that region only. To ensure a similar experience to people all around the world we can use Azure CDN.
The Azure Content Delivery Network (CDN) distributes content across geographic regions to edge nodes across the globe. The CDN caches publicly available objects so they are available over high-bandwidth connections, close to the users, thus allowing the users to download them at much lower latency. By default, blobs have a seven-day time-to-live (TTL) at the CDN edge node. After that time elapses, the blob is refreshed from the storage account to the edge node. Blobs that are shared via CDN must support anonymous access.
In this case, if someone wants to access an asset from a particular storage group integrated with CDN like a video or image file, they will use a different URL, that is of the CDN instead of that of the storage account which will route the request to the closest edge server. And if the closest edge server didn’t have the content requested for, it will retrieve the content from the original server have a copy of the same there. The consecutive requests also will be directly routed to the closest edge server. This is very useful in the case of having a global user base where the load of the single origin will be distributed to multiple edge servers across the world.
In this article, we will set up a CND profile for our current storage account.
Log in to your Microsoft Azure portal, click on Create new resource and select CND from Web category to create a CDN Profile, check Create CDN endpoint now also and give the necessary details as follows and click on create.
- Name: A proper name for identification
- Subscription: Select your Subscription
- Resource group: Create a new named CDN (Just to store the CDN Profile, nothing to do with the edge servers)
- Location: Nearest to you
- Pricing Tier: Select Standard Akamai (As Verizon will take much time for initial caching)
- CDN endpoint name: A unique name
- Origin type: Storage
- Origin hostname: Select your storage account URL from the drop-down list
Once the deployment is successful, open the resource and there you can see our endpoint listed there. There you have a provision for adding more endpoints for different resource types if required, and selecting the endpoint will show the dashboard for the specific endpoint where you can add Custom domains, Geo filtering or Purge the connection.
Now, let’s verify that our CDN is working fine by accessing content from our blob container by using our newly created CDN endpoint’s hostname. In our storage account, we we have many files with a URL of the format.
Now, we are accessing the same via using our CDN by replacing the hostname with that of the CDN of the format [cdnname].azureedge.net/[containername]/filename
There is a provision for enabling CDN replication to a particular container or subfolder only within a storage account like enabling CDN for videos alone. You can set the same from the origin tab of the endpoint by specifying the path.