Originally when I setup my blog on Static website hosting in Azure Storage I went with Azure CDN because I wanted to have an SSL endpoint. As of right now, you cannot do custom SSL with static website hosting unless you use Azure CDN.
But then I hit another snag, you cannot redirect the root domain and redirects in general were a bit too complex for a simple project like this one. There is a user voice suggestion for this feature but it remains under review. This started to bother me because I wanted to do redirects with SSL but couldn’t because the I could not install the certificate generated by Azure CDN on the Linux VM I decided to do the rewrites on. All my previous articles were on https://hammertime.tech breaking all of my links from places like Google and Bing, or even worse resulting in the dreaded SSL error.
Fast forward a bit to Cloudflare. In a previous life I used their free plan to protect against attack but that free plan also offers 3 free redirects AND a free SSL endpoint. This meant I could now redirect https://hammertime.tech to www. where my CNAME is setup for Azure Storage. It also meant I could redirect a bunch of my other domains like hammertimetech.com and have all my URLs work how I wanted. Nobody else will probably notice this.. but it’s one of those things I wanted in place - I am weird like that!
But I digress, now that I am on Cloudflare I wanted to make sure that the Cloudflare CDN cache has my latest content whenever I publish. This is probably overkill in some places because Cloudflare seems to pick up on new content fairly quickly. But at least at the end of my release pipeline I’ll know everything is published on the CDN.
This guide assumes a few things are already done.
- You’ve setup a Cloudflare account and your domain is pointed to their name servers for hosting. You can find instructions in Cloudflare 101.
- You’ve already setup your CNAME to point to Azure Storage (or other endpoint).
- You have obtained your API Token for the v4 API
- You already have a release pipeline setup, see my previous article for more information.