Azure CDN
What is azure CDN?
- Its a tool which help us to reduce the response time of a particular transaction on web.
- it will help to cache the data to the nearest server which are there for the user
- We can cache content in azure blob storage by using the closest point of presence( POP ) server
Prerequisites
If you want to follow along with this example, there are a few things you will need.
- An Azure Subscription
- A Storage Account configured to host a static website
- Some kind of content hosted in the static website. This example is based on a Blazor Web Assembly application, but it could just as easily be a single HTML page.
Step 1: Provision an Azure CDN Endpoint for your Static Website
An Endpoint is a separate Azure resource that lives under a CDN Profile resource, but you can create one for your static website directly from the Storage Account blade.
- Go to your Storage Account in the Azure Portal
- Scroll down the menu until you see Azure CDN (it is under Blob service) and click on it to reveal the Azure Content Delivery Network settings
- Under New endpoint, we’ll enter details to setup a new CDN profile and endpoint.
- Leave Create new selected and enter a name for your CDN profile
- Choose Standard Microsoft for the Pricing tier (it is the cheapest and good enough for this example).
- Enter a CDN endpoint name (this needs to be unique on azureedge.net)
- Select your Static Website in the Origin hostname dropdown
- Click on Create. Grab a cup of coffee whilst the CDN endpoint is provisioned.
Once the provisioning is complete, click on the endpoint. In the Overview of the endpoint that is displayed, you will find the Endpoint hostname (it will be something like https://yourendpointname.azureedge.net). If you browse to this address you should see your static site.
Step 2: Configure a Global Rule to Append an HTTP Header to All Response
Now that our CDN endpoint is provisioned, let’s use the Rules Engine to add a custom HTTP Header to every response.
- Go to your newly create Endpoint in the Azure Portal
- Click on Rules engine in the menu (under Settings)
- We want to append a custom header to every response, so we want to use the Global rule rather than adding a new rule. Click on Add Action in the Global Rule and select Modify Response Header.
- Enter values for the Modify response header fields. The examples below are for specifying a blazor-environment header with value CI:
- Action: Append
- HTTP Header Name: blazor-environment
- HTTP Header Value: CI
- Click on Save in the top menu bar. The portal will inform you that it is saving your endpoint changes. It can take up to 10 minutes for the changes to propagate, so grab some more coffee or read a book for a bit.
Azure front door
Microsoft Azure provides a wide suite of services to make your sites and services highly available across geographic regions. Since Azure Front Door became Generally Available, there is often a question around what would be the right choice between Azure Front Door and Azure CDN delivery of your highly availability sites and content.
Why azure front door ?
But when you are working with larger documents, Front Door uses object chunking method to request the document in smaller parts.Front Door caches any chunks as they’re received so the entire file doesn’t need to be cached on the Front Door cache. Subsequent requests for the file or byte ranges are served from the cache.
Get Arjun PT’s stories in your inbox
Join Medium for free to get updates from this writer.
Azure offers delivery of your sites and services through a CDN of Microsoft WAN Edges and in the process enhances the performance of your services in addition to providing high availability.
Azure Front Door routes incoming requests to a primary region. If the application running that region becomes unavailable, Front Door can fail over to the secondary region.
When you are requesting a large document, Azure Front Door uses object chunking method to request the document in smaller chunks and caches it. This process continues until the entire file is downloaded (if requested), all byte ranges are available (if requested), or the client terminates the connection.
Scenario:
have a Azure static website that will displaying the data (mainly office files and videos) from Azure blob storage. The files in blob storage will rarely change. I am looking for the best way and cheapest way to cache these files, so that files can be fetched quickly.
Azure CDN:
- Azure CDN is globally distributed network of servers that can deliver content to the customers in a very large scale.
- It is a video streaming platform where videos are delivered based on the customer’s nearest edge location.
- Azure CDNs stores cached content on the edge servers which results in minimizing network latency.
Azure Front door:
- It provides Scalable, secure and fast delivery of your global applications .
- It enables you to define, manage, and monitor the global routing for your web traffic.
- It provides best performance and instant global failover for high availability.
Based on your scenario, that best caching you can use is Azure CDN due to the following:
- Azure CDN is best for delivering static content like Videos, Images and PDFs whereas Azure Front Door is for delivering sites, services and APIs.
- Azure CDN is cost-effective whereas Azure Front Door charges per ruleset.
- Azure CDN does all the functionality similar to Azure Front Door.
- Azure CDN performs a good job at content delivery at a cheaper price!.
Hand-On:
- lets create a blob storage account in central us and then create a container inside it where we can upload the file and change the access level to container level
2. Inside the storage account we can see a CDN
here the origin hostname will be the blob and pricing tier we can go with the standard one
we can access the website now using the CDNendpoint
CDN Hand-on:
Once the CDN profile is created follow the below steps
once everything is ready make sure that in container we enable from all networks on the storage section.
In order to render the application through cdn use the cdn endpoint/filename.
- we have a rule engine to set the cache expiration time and all







