Bad Experiences with Azure CDN

May 31, 2022

As of writing this, I'm just coming home from a long day of work dealing with Azure CDN. We are hosting Web Applications and Websites on Azure Kubernetes (AKS). We manage all our infrastructure using Terraform. So it felt natural to also use Azure CDN. But for us, it is unusable. Here are the two reasons why.

Custom domains need to exactly match the DNS config

This means that you need to create your CNAME entry before you can create your endpoint and, consequently, you need to delete your CNAME entry before you can delete your endpoint. I get the idea behind this feature, but I think with the way how DNS works, this can be cumbersome.

The workarounds described did not work for us, even though the feature seems to be activated. At least az feature list is telling us this. If you manage the domain with terraform and change it, you always need to deploy twice. Once for deleting the old domain and another time for creating the new one. This causes a lot of failed CI/CD pipelines.

You can not cache based on the "Accept"-Header

We are caching media assets, such as images or videos. Based on the Accept-Header we deliver the ideal file format for each user. This is not possible with Azure CDN because it simply throws away the Accept-Header. For us, this meant that we would always deliver only one format. We tried to fiddle around with cache rules so that we only cache the "best" format and otherwise bypass cache, but we had no luck.

Our temporary solution was to use CloudFront again, even though we would like to have a CDN that supports Stale-While-Revalidate, which CloudFront does not yet.

Daniel Karnutsch Portrait
Daniel Karnutsch
Indie Developer and Soluation Architect from Salzburg. I like Web Development, Containers and Travelling
Tweet