What is a CDN?
A CDN is a global network of servers (called Points of Presence, or PoPs) that cache copies of your content close to users worldwide. When a user requests a file:
- The CDN routes the request to the nearest PoP
- If the PoP has the file cached, it returns it immediately (cache hit)
- If not, it fetches from your storage account (origin), caches it, and returns it
- Subsequent requests from that region are served from the cache
Azure CDN Tiers
| Tier | Provider | Best For |
|---|---|---|
| Azure CDN Standard from Microsoft | Microsoft | General use, integrated with Azure services |
| Azure CDN Standard from Edgio | Edgio (formerly Verizon) | Broad coverage, good performance |
| Azure CDN Premium from Edgio | Edgio | Advanced rules engine, analytics |
Creating a CDN Endpoint for Blob Storage
Via Azure Portal
- Go to your Storage Account → Security + networking → Azure CDN
- Click + New endpoint
- Select your CDN profile (or create new)
- Set endpoint name (must be globally unique — becomes
[name].azureedge.net) - Set Origin type: Storage
- Set Origin hostname: your storage account's blob endpoint
- Click Create
Via Azure CLI
# Create CDN profile
az cdn profile create \
--name mycdnprofile \
--resource-group myResourceGroup \
--sku Standard_Microsoft \
--location global
# Create CDN endpoint pointing to blob storage
az cdn endpoint create \
--name mysite-cdn \
--profile-name mycdnprofile \
--resource-group myResourceGroup \
--origin mystorageaccount2026.blob.core.windows.net \
--origin-host-header mystorageaccount2026.blob.core.windows.net \
--location global
Your content is now accessible at: https://mysite-cdn.azureedge.net
Adding a Custom Domain
- In your DNS provider, create a CNAME record:
www.yoursite.com→mysite-cdn.azureedge.net - In the Azure Portal, go to your CDN endpoint → Custom domains → + Custom domain
- Enter
www.yoursite.com - Azure validates the CNAME record
- Click Add
Enabling HTTPS
Azure CDN provides a free managed SSL certificate for custom domains — no need to purchase or manage certificates yourself.
- Go to your CDN endpoint → Custom domains → click on your domain
- Toggle Custom domain HTTPS to On
- Select CDN managed certificate
- Click Save
- Azure automatically provisions and renews the certificate (takes a few hours first time)
az cdn custom-domain enable-https \
--endpoint-name mysite-cdn \
--profile-name mycdnprofile \
--resource-group myResourceGroup \
--name www-yoursite-com
Caching Rules
By default, CDN caches content based on the Cache-Control headers from your origin. You can override this with caching rules:
| Rule Type | Use Case |
|---|---|
| Global caching rule | Default TTL for all content (e.g., cache everything for 1 day) |
| Custom caching rule | Different TTL for specific paths (e.g., images cached 30 days, HTML cached 1 hour) |
| Query string caching | Cache differently based on query parameters |
Purging the Cache
When you update content in your storage account, the CDN cache still serves the old version until it expires. Purge the cache to force CDN to fetch fresh content:
# Purge specific path
az cdn endpoint purge \
--name mysite-cdn \
--profile-name mycdnprofile \
--resource-group myResourceGroup \
--content-paths "/images/logo.png"
# Purge everything
az cdn endpoint purge \
--name mysite-cdn \
--profile-name mycdnprofile \
--resource-group myResourceGroup \
--content-paths "/*"
Cost Savings with CDN
CDN can actually reduce your total storage costs despite its own fees:
- Storage egress (outbound data) costs ~₹6/GB from Azure Storage
- CDN egress is cheaper — ~₹4–5/GB depending on region
- Cache hits don't cost storage egress at all — only the first request to origin
- If 90% of requests are cache hits, you've reduced storage egress by 90%
[name].azureedge.net.