Azure CDN

How it works?

Azure Content Delivery Network (CDN) is a CDN service provided by Azure Cloud Platform that enables storing and accessing data on different content servers and locations – used by online or cloud services.  A CDN store the content cached on the edge servers that are available in the POP locations to reduce latency. Azure CDN is important for us which requires multiple hits to boost up the process of our applications.

Benefits of using Azure CDN –

  • Better performance and improved user experience for end users
  • Large scaling to better handle instant high loads
  • Distribution of user requests and serving of content directly from edge servers so that less traffic gets sent to the origin server.

Working Of Azure CDN :

  • The working of the Azure CDN commences when a user requests a file or asset with the help of an URL. They use a specific domain name for putting up their request, which can also be a custom domain or an endpoint hostname. The DNS is then responsible for directing the request to the nearest POP location. It automatically picks the POP that is closed to the geographical location of the user.
  • If no edge servers in the POP have the file in their cache, the POP requests the file from the origin server. The origin server can be an Azure Web App, Azure Cloud Service, Azure Storage account, or any publicly accessible web server.
  • The origin server returns the file to an edge server in the POP.
  • The role of the edge server is to cache the file and then return it to the user who requested the same. It caches the file within the POP to make it available for other users who request it next time. But there is a limitation for that file to remain in the cache.
  • The remains cached on the edge server in the POP location until the time-to-live (TTL) specified by its HTTP headers expires. If the origin server didn’t specify a TTL, the default TTL is seven days.
  • If the TTL for the file hasn’t expired, the POP edge server returns the file directly from the cache. This process results in a faster, more responsive user experience.

Requirements to create Azure CDN :

  • Must have an active subscription to Azure.
  • You need and create your CDN profile that has the CDN endpoints. Every CDN endpoint is a specific configuration that users can customize with required content delivery behavior and access.
  • The pricing of Azure CDN depends upon the CDN profile levels. For using the mix of pricing tiers, you need to go ahead and create multiple CDN profiles.

Limitations of Azure CDN :

Each Azure subscription has default limits to create How many CDN profiles will have created and the maximum number of endpoints will have created in each CDN profile. And How many custom domains will have been mapped to a single endpoint.

For more information on CDN Limitations pls go through the MS doc of CDN limits.

Azure CDN Features :

  • Dynamic site acceleration via Azure CDN
    • Azure CDN caching behavior – Azure CDN provides two types of caching rules: global and custom.
    • Global caching rules – You can set one global caching rule for each endpoint in your profile, which affects all requests to the endpoint. The global caching rule overrides any HTTP cache-directive headers, if set.
    • Custom caching rules – You can set one or more custom caching rules for each endpoint in your profile. Custom caching rules match specific paths and file extensions, get processed in order, and override the global caching rule, if set.
    • HTTPS Custom Domain Support

For more info about CDN features pls go through this Doc Azure CDN features

Step to create Azure CDN profile and End points –

There are different methods to create a CDN profile but in this blog, we will create using terraform. By the way, We have multiple terraform modules to create infrastructure in Azure. You can also check out this repo to use multiple terraform modules of Azure services.

  • Azure Terraform CDN  module can be found in this repo
  • Please check below main.tf file.  Same insert the values as per your requirements.
module "cdn_profile" {
source = "https://github.com/OT-terraform-azure-modules/terraform-azure-cdn.git"
resource_group_name = module.res_group.resource_group_name
location  = module.res_group.resource_group_location
storage_account_name = "_"
storage_container_name = "_"
storage_blob_name = "_"
cdn_profile_name = "_"
cdn_endpoint_name = "_"
}

CONCLUSION

This article is covered the basic required points of Azure CDN. This is an inexpensive and easy to configure to use the service provided by Azure. Apart from some possibilities shown in this blog, It can be possible to configure some parameters such as caching by time or caching by directories. You can use the given Azure CDN terraform module to create it. Please go through the README.md of the module.

Blog Pundits: Mehul Sharma and Sandeep Rawat

OpsTree is an End-to-End DevOps Solution Provider.

Connect with Us

One thought on “Azure CDN”

Leave a Reply