0
0
Azurecloud~5 mins

Purging CDN cache in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
Sometimes, when you update your website or app content, the old version still shows because it is saved in the CDN cache. Purging the CDN cache removes these old files so visitors see the newest content right away.
When you update images or files on your website and want users to see the changes immediately.
When you fix a bug in your web content and need to remove the cached broken version.
When you deploy a new version of your app and want to clear old cached files to avoid confusion.
When you want to test changes and need to make sure the CDN is not serving outdated content.
When you notice your users are seeing stale content due to caching delays.
Commands
This command clears all cached content from the specified CDN endpoint so that users will get fresh content on their next request.
Terminal
az cdn endpoint purge --resource-group example-resource-group --profile-name example-cdn-profile --name example-endpoint --content-paths '/*'
Expected OutputExpected
Starting purge operation... Purge operation completed successfully.
--resource-group - Specifies the Azure resource group where the CDN profile is located.
--profile-name - Specifies the name of the CDN profile that contains the endpoint.
--content-paths - Specifies which cached paths to purge; '/*' means all cached content.
This command checks the status of the CDN endpoint to confirm it is active and ready after the purge.
Terminal
az cdn endpoint show --resource-group example-resource-group --profile-name example-cdn-profile --name example-endpoint
Expected OutputExpected
{ "id": "/subscriptions/xxxx/resourceGroups/example-resource-group/providers/Microsoft.Cdn/profiles/example-cdn-profile/endpoints/example-endpoint", "name": "example-endpoint", "resourceGroup": "example-resource-group", "status": "Running", "type": "Microsoft.Cdn/profiles/endpoints" }
--resource-group - Specifies the resource group of the CDN profile.
--profile-name - Specifies the CDN profile name.
Key Concept

If you remember nothing else from this pattern, remember: purging the CDN cache forces the CDN to fetch fresh content from your origin server immediately.

Common Mistakes
Not specifying the correct resource group or profile name in the purge command.
The command will fail or purge the wrong CDN endpoint, leaving your content stale.
Always double-check the resource group and profile name to target the correct CDN endpoint.
Using incorrect content paths or forgetting to include '/*' to purge all content.
Only partial or no cached content will be purged, so users may still see old files.
Use '/*' to purge all cached content or specify exact paths you want to clear.
Summary
Use 'az cdn endpoint purge' with the right resource group, profile, and endpoint to clear cached content.
Use 'az cdn endpoint show' to verify the CDN endpoint status after purging.
Purging forces the CDN to serve fresh content from your origin server immediately.