0
0
Azurecloud~15 mins

Purging CDN cache in Azure - Mini Project: Build & Apply

Choose your learning style9 modes available
Purging CDN Cache in Azure
📖 Scenario: You manage a website hosted on Azure and use Azure CDN to deliver content quickly to users worldwide. Sometimes, you update your website content and need to clear the cached files on the CDN so visitors see the latest version immediately.
🎯 Goal: Build a simple Azure CLI script that purges the CDN cache for specific paths, ensuring the latest content is served to users.
📋 What You'll Learn
Create a variable with the Azure CDN profile name
Create a variable with the Azure CDN endpoint name
Create a list variable with the paths to purge
Write the Azure CLI command to purge the CDN cache using the variables
💡 Why This Matters
🌍 Real World
Websites and apps use CDNs to speed up content delivery. When content changes, purging the CDN cache ensures users see the latest version quickly.
💼 Career
Cloud engineers and DevOps professionals often automate CDN cache purging to maintain content freshness without manual steps.
Progress0 / 4 steps
1
Set Azure CDN profile name
Create a variable called cdn_profile and set it to the exact string myCdnProfile.
Azure
Need a hint?

The CDN profile name is the name of your Azure CDN profile.

2
Set Azure CDN endpoint name
Create a variable called cdn_endpoint and set it to the exact string myCdnEndpoint.
Azure
Need a hint?

The CDN endpoint is the specific endpoint under your CDN profile.

3
Define paths to purge
Create a list variable called paths_to_purge with these exact strings: "/images/*" and "/css/*".
Azure
Need a hint?

Paths specify which cached files to clear on the CDN.

4
Write Azure CLI purge command
Write a string variable called purge_command that contains the exact Azure CLI command to purge the CDN cache using cdn_profile, cdn_endpoint, and paths_to_purge. The command should be: az cdn endpoint purge --profile-name {cdn_profile} --name {cdn_endpoint} --resource-group myResourceGroup --content-paths {paths_to_purge} where {paths_to_purge} is a space-separated string of the paths.
Azure
Need a hint?

Use an f-string to insert variables and join the paths with spaces.