tabs ↹ over ␣ ␣ ␣ spaces

by Jiří {x2} Činčura

Using Azure CDN for complete static (running) website

20 Oct 2017 3 mins Azure, CDN, Cloud

If you read the documentation etc. for Azure CDN, it often expects that you’re going to use it on parts of your website and rest will be served directly from the original location. But if you have completely static (and currently running) website, like for example this blog, which is using the Azure CDN actually, you need to take a few specific steps to start using Azure CDN in such setup and without downtime.


For this blog post I’m going to use as a domain for the website and as a name for the Web App where the website is hosted. The CDN endpoint will be

Step 1

As a first step, because it needs some time to propagate, you need to create verification CNAME record on your DNS. Create CNAME record that points to

This will help us verify the domain later on, while the CDN is still being created.

Step 2

Create an CDN profile in Azure and create an endpoint. While setting up the endpoint, use custom origin and as an origin. Use Host header depends on your configuration, i.e. redirects. Generally,

This might look weird, because a lot of tutorials etc. will tell you to use the domain as an origin (or select from the menu correct Web App). Because we want to use CDN for the whole domain, you can’t use the domain as origin. The fetching would then end up in an infinite loop.

Step 3

Set the custom domain for the endpoint to be This is where the Step 1 comes handy because you’re not ready to change the DNS for the domain itself. Depending on state of DNS propagation you might wait few minutes or hours before completing this step.

Step 4

Enable HTTPS for the CDN. This is as simple as flipping the switch in Azure portal and waiting for the verification and certificate installation. The verification is well described, and it’s the same process no matter what kind of CDN setup you’re trying to do, so I’m not going to describe it here. The certificate installation and propagation on all POP nodes takes a while (basically hours). I usually do this as a last thing before leaving my office and continuing the next day.

Although this is optional, nowadays I expect every website to have HTTPS enabled.

Step 5

Now you can finally change the DNS for pointing it to, via CNAME, to After this you can delete the original record (although it’s not going to break anything if left there).


And you’re done. If you followed these steps no downtime should happen and after a few minutes or hours and the website will slowly become available via CDN, hopefully faster for the end users.

Profile Picture Jiří Činčura is .NET, C# and Firebird expert. He focuses on data and business layers, language constructs, parallelism, databases and performance. For almost two decades he contributes to open-source, i.e. FirebirdClient. He works as a senior software engineer for Microsoft. Frequent speaker and blogger at