0
0
AzureHow-ToBeginner · 4 min read

How to Use Azure CDN with Storage for Fast Content Delivery

To use Azure CDN with Azure Storage, create a CDN profile and endpoint that points to your storage account's blob service URL. This setup caches your storage content globally, speeding up delivery to users.
📐

Syntax

To connect Azure CDN with Azure Storage, you need to create a CDN endpoint linked to your storage account's blob service URL. The main parts are:

  • CDN Profile: A container for CDN endpoints.
  • CDN Endpoint: The URL that users access, which points to your storage.
  • Origin: The Azure Storage blob URL serving as the source.
bash
az cdn profile create --resource-group <resource-group> --name <cdn-profile-name> --sku Standard_Microsoft
az cdn endpoint create --resource-group <resource-group> --profile-name <cdn-profile-name> --name <endpoint-name> --origin <storage-account-name>.blob.core.windows.net
💻

Example

This example shows how to create a CDN profile and endpoint for an Azure Storage account named mystorageaccount in resource group myResourceGroup. It enables fast global delivery of blobs.

bash
az cdn profile create --resource-group myResourceGroup --name myCdnProfile --sku Standard_Microsoft
az cdn endpoint create --resource-group myResourceGroup --profile-name myCdnProfile --name myCdnEndpoint --origin mystorageaccount.blob.core.windows.net
Output
Profile 'myCdnProfile' created. Endpoint 'myCdnEndpoint' created and linked to origin 'mystorageaccount.blob.core.windows.net'.
⚠️

Common Pitfalls

  • Not using the full storage blob URL as the origin causes CDN to fail.
  • For private storage blobs, CDN needs proper authentication setup; otherwise, content won't load.
  • For HTTPS delivery, ensure the CDN endpoint has a valid certificate.
  • Remember to purge CDN cache after updating storage content to see changes immediately.
bash
Wrong origin example:
az cdn endpoint create --resource-group myResourceGroup --profile-name myCdnProfile --name myCdnEndpoint --origin mystorageaccount

Right origin example:
az cdn endpoint create --resource-group myResourceGroup --profile-name myCdnProfile --name myCdnEndpoint --origin mystorageaccount.blob.core.windows.net
📊

Quick Reference

StepCommand/ActionDescription
1az cdn profile createCreate a CDN profile to hold endpoints
2az cdn endpoint createCreate an endpoint pointing to storage blob URL
3Configure HTTPSEnable HTTPS for secure content delivery
4Purge CDN cacheClear cached content after updates

Key Takeaways

Create a CDN profile and endpoint pointing to your storage blob URL to enable Azure CDN.
Always use the full storage blob URL as the CDN origin to avoid connection issues.
Configure HTTPS on the CDN endpoint for secure content delivery.
Purge CDN cache after updating storage content to reflect changes quickly.
For private blobs, set up authentication to allow CDN access.