Set Up Microsoft CDN via Azure – Step-by-Step Guide & Pricing Inside
Set Up Microsoft CDN via Azure – Step-by-Step Guide & Pricing Inside
Microsoft Azure CDN (Content Delivery Network) helps you deliver your website or app content quickly and reliably to users across the globe. By caching your files on edge servers closer to visitors, you can dramatically improve load times, reduce bandwidth costs on your origin server, and boost overall performance and scalability.
What Is Azure CDN?
Azure CDN is a globally distributed network of servers optimized to deliver static and dynamic content (images, CSS, JavaScript, videos, downloads, APIs, and more). When a user requests an asset, Azure CDN routes the request to the closest edge location, reducing latency and improving user experience.
- Lower latency – Files are served from a location geographically closer to the user.
- Offloaded origin – Your web server or storage account serves fewer requests.
- Better scalability – Traffic spikes are absorbed by the CDN edge network.
- Security features – HTTPS, custom domains with TLS, and integration with Azure Front Door and WAF.
Azure CDN SKUs / Products Overview
When you create a CDN profile in Azure, you must select a pricing tier (SKU). Each SKU is backed by a specific provider and offers slightly different capabilities:
-
Standard Microsoft
Best if you want tight integration with other Azure services, built-in rules engine, and features like compression & query-string caching. -
Standard Akamai
Uses Akamai’s global network, suitable for large-scale static content delivery, and common web acceleration scenarios. -
Standard Verizon
General-purpose CDN with HTTP/HTTPS delivery, compression, and caching rules. -
Premium Verizon
Adds an advanced rules engine and more granular control over behavior at the edge (rewrites, device detection, etc.).
For most new deployments, Standard Microsoft is a solid default choice unless you need a specific feature from Akamai or Verizon-based SKUs.
Prerequisites
- An active Azure subscription.
- Content hosted in Azure (e.g., Azure Storage static website or App Service) or an external origin (e.g., on-premise server, other cloud).
- Optionally, a custom domain (e.g.,
cdn.example.com) if you don’t want to use the default.azureedge.nethostname.
Step 1 – Create a CDN Profile
- Sign in to the Azure Portal.
- In the left-hand menu, select Create a resource, then search for CDN and choose CDN profile.
- Click Create.
-
Fill in the basics:
- Subscription: pick your Azure subscription.
- Resource group: select an existing group or create a new one (e.g.,
rg-cdn-prod). - Resource name: e.g.,
my-azure-cdn-profile. - Region: for CDN profiles this is largely a metadata location, but choose something close to your operations (e.g., West Europe, East US).
- Pricing tier: pick Standard Microsoft (or another SKU if you prefer).
- Click Review + create, then Create.
Wait until deployment is complete, then open the CDN profile resource.
Step 2 – Create a CDN Endpoint
An endpoint is the actual hostname from which users will fetch content (e.g., myapp.azureedge.net).
- Within your CDN profile, select + Endpoint or Add endpoint.
-
Configure the endpoint:
-
Endpoint name: this becomes part of the URL, e.g.,
mycdnendpoint.azureedge.net. -
Origin type:
- Storage – for Azure Blob Storage or static website hosting.
- Web App – for Azure App Service.
- Cloud service – for classic cloud services.
- Custom origin – any public hostname or IP (including on-premise or other cloud providers).
-
Origin hostname: specify the domain where your content currently lives, such as:
myaccount.blob.core.windows.net(for storage)myapp.azurewebsites.net(for App Service)- Or your own origin:
origin.example.com
- Origin host header: usually same as the origin hostname unless you use a different host header.
-
Origin path (optional): specify a subfolder or app path (e.g.,
/static). - Protocol / Ports: enable HTTPS by default; HTTP is optional if you still support it.
-
Endpoint name: this becomes part of the URL, e.g.,
- Click Add to create the endpoint.
After creation, Azure will begin to propagate the CDN endpoint configuration worldwide. This can take a few minutes.
Step 3 – Test Your CDN Endpoint
-
Go to your CDN endpoint in the Azure Portal and note its Endpoint hostname, e.g.,
mycdnendpoint.azureedge.net. -
Open a browser and request a static asset through the CDN URL, such as:
https://mycdnendpoint.azureedge.net/images/logo.png - If the origin is configured correctly and the file exists there, you should see it load via CDN.
-
Use browser dev tools (Network tab) or command-line tools like
curl -Ito inspect response headers. You should see headers such as:X-Cache: TCP_HITorTCP_MISSVia: 1.1 azureedge.net
Step 4 – Configure Caching Rules
Caching behavior can be controlled via HTTP headers (set on your origin) and/or via Azure CDN rules engine or caching rules.
Use Origin Cache-Control Headers
On your origin server or app, set headers like:
Cache-Control: public, max-age=31536000
This tells the CDN and browsers to cache content for up to one year (for versioned static assets like app.12345.js).
Set Caching Rules in Azure CDN
- Open your CDN endpoint in the Azure Portal.
- Find Caching rules or Rules engine (depending on SKU).
-
Create rules such as:
- Cache static file extensions (
.css,.js,.jpg,.png, etc.) for a long time. - Bypass or shorten cache for dynamic pages (e.g.,
.aspx,.php, APIs).
- Cache static file extensions (
- Save and wait for propagation.
Step 5 – Configure a Custom Domain (Optional)
By default, your CDN endpoint uses a URL like mycdnendpoint.azureedge.net. You can map your own domain, such as cdn.example.com.
- Buy or use an existing domain managed through your DNS provider.
- In the Azure Portal, open your CDN endpoint and go to Custom domains.
- Click + Custom domain.
-
Enter your custom hostname, e.g.,
cdn.example.com. -
In your DNS provider, create a CNAME:
cdn.example.com CNAME mycdnendpoint.azureedge.net - Once DNS has propagated, complete the validation in Azure.
Enable HTTPS on Custom Domain
- Open the custom domain configuration under your CDN endpoint.
- Enable HTTPS for the domain.
-
Choose certificate option:
- CDN managed certificate (recommended) – Automatic provisioning and renewal.
- Bring your own certificate – Use a certificate from your own CA or Key Vault.
- Save and wait for SSL provisioning (can take from 5 to 60 minutes).
Step 6 – Integrate CDN URLs into Your App
To fully benefit from Azure CDN, update your application or website to load static content through the CDN-based URLs.
-
HTML templates:
Replace:
<img src="/images/logo.png" />
with:
<img src="https://cdn.example.com/images/logo.png" /> -
CSS/JS references:
Use absolute CDN URLs for scripts and stylesheets. -
Static asset pipeline:
If you use bundlers (Webpack, Vite, etc.), configurepublicPathor asset prefix to point to the CDN domain.
After updating, redeploy your app and verify that assets are loading from the CDN in your browser’s network tab.
Azure CDN Pricing Overview
Azure CDN pricing depends on:
- Data transfer out (per GB) – varies by geographic zone.
- Requests (for some SKUs) – e.g., per 10,000 or per million requests.
- Rules engine – advanced rules may have additional cost depending on SKU.
- Additional features – e.g., premium rules, security add-ons, or custom domains for some providers.
Typical Cost Structure
Exact prices change over time; always check the official calculator, but the structure generally looks like this:
-
Standard Microsoft:
- Outbound data transfer tiered by GB per month and by region (e.g., North America, Europe, Asia).
- First usage tier is more expensive per GB, and higher usage tiers are cheaper.
-
Standard/Premium Verizon & Standard Akamai:
- Similar regional tiers, sometimes slightly different rates.
- Additional charges possible for advanced rules or security features.
To estimate monthly cost:
- Sum up expected monthly outbound traffic to users (e.g., 1 TB = 1024 GB).
- Use the Azure Pricing Calculator and select Content Delivery Network.
- Choose your SKU (e.g., Standard Microsoft) and the regions where traffic will originate.
- Enter estimated data transfer volumes per region.
Example: If you expect 500 GB per month served mostly to North America and Europe from Standard Microsoft CDN, you might spend only a few tens of dollars per month, depending on current per‑GB rates.
Optimizing Costs
- Cache aggressively for static assets (long
max-age), so repeated requests are served from edge cache. - Compress text assets (Gzip/Brotli) to reduce transfer size.
- Use versioned file names (e.g.,
app.v1.js) so you can cache indefinitely and only break cache when needed. - Exclude unnecessary content – don’t serve large backups or internal-only assets via CDN unless required.
Monitoring & Troubleshooting
Azure provides several tools to monitor your CDN traffic and performance.
-
Metrics – In the CDN endpoint, view metrics such as:
- Requests
- Bytes served
- Cache hit ratio
- Logs – Integrate with Azure Monitor or Log Analytics for detailed access logs.
- Rules / configuration debugging – Temporarily disable rules or use test URLs to verify caching behavior changes.
Common issues:
- 404 Not Found: The asset may not exist on the origin, or the origin path is misconfigured.
- No caching / always MISS: Check your
Cache-Controlheaders and CDN caching rules. - SSL errors on custom domain: Wait for certificate provisioning or verify CNAME and domain ownership.
When to Use Azure CDN
Azure CDN is ideal when:
- You serve static assets (images, CSS, JavaScript) to users worldwide.
- Your web app experiences traffic spikes or high concurrency.
- You want to reduce latency for globally distributed users.
- You need better resiliency and offload from your origin infrastructure.
For more complex global routing, security policies, and WAF, you can also look into Azure Front Door, which works well alongside or on top of CDN capabilities.
Conclusion
Setting up Microsoft Azure CDN involves creating a CDN profile, configuring an endpoint that points to your origin, testing content delivery, optionally adding a custom domain with HTTPS, and then integrating the CDN URL into your application. With proper caching rules and optimization, Azure CDN can significantly improve load times while keeping bandwidth and infrastructure costs under control.
If you want to go even deeper into configuration details and example pricing scenarios, read the full step-by-step guide here: Set Up Microsoft CDN via Azure – Step-by-Step Guide & Pricing Inside .
```
Comments
Post a Comment