Configure Cloudflare
The following article explains how to configure Cloudflare to deliver your website using their content delivery network. This article assumes you have already created your Cloudflare account.
Add a site
Head over to the Cloudflare Dashboard and once logged in click 'Add a site'.
Enter your domain name without www. and then click add site.
Then select a plan and click the Confirm Plan button.
Next, Review your DNS records, Cloudflare will try and fetch your DNS records automatically. You should see the DNS records we created earlier. We do not need the 'asvirify' record. So the only record we need for the website to work is the one CNAME record. You may have more records if you have any emails setup.
Click the Continue button.
Now we need to update our domain's 'Name servers' to point to Cloudflare. You can see in the image below Cloudflare is showing us our current name server settings and telling us what to update them too.
Open a new tab and head over to your domain registrar (where you brought your domain). In this example, We are using Google Domains, but the principle will be the same across all registrars.
Find your domain's 'Name servers' section, if you are using Google Domains, click the DNS tab and at the top, there is a section that says "Name servers", simply enter the new name servers that Cloudflare gave us in the last step.
Your new name servers section should look similar to the image below.
Now head back over to Cloudflare and click the Done button.
Then scroll down to the 'Always Use HTTPS' section and toggle it on. This will tell Cloudflare to force the connection to use https.
Then scroll to the bottom and click done.
Now the next two steps are optional but recommended. We are going to tell Cloudflare to redirect any visitors not using www. or https to use www. and https.
From the Cloudflare dashboard select the DNS tab.
Then click the 'add record' button, select CNAME as the type and enter '@' for the name and enter the storage accounts endpoint as the target. Then click done.
Then click the 'Page Rules' tab, and click the 'Add Page Rule' button.
In the first field enter your domain without www. and ending with /* (see image below).
In the pick a setting dropdown select 'Forwarding URL'.
In the select staus code dropdown select '301 - Permanent redirect'.
In the destination URL field enter your domain starting with https://www. and ending with $1 (see image below).
Click Save and Deploy. Note these settings may take a couple of hours to start working.
Learn more about URL forwarding and redirects on this page at cloudflare.
If all went well you should see the below message on the overview tab, if not wait 10-15 minutes and refresh the page.
Now open a new tab and enter your domain to visit your published site.