Add Custom Domain
The following article explains how to set up a custom domain, For example, www.mynewwebsite.com.
To set up a custom domain all we need to do is simply update our domains DNS settings.
Add Custom Doamin
Go to your websites Storage Account within Azure and go to the Static Website tab. All we need to do here is copy the Primary Endpoint URL without 'https://' and without the end '/' see image below.
Update DNS Records
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 DNS records, if you are using Google Domains, simple click the DNS tab and scroll down to the bottom where it says "Custom resource records".
Now, all we need to do is simply add two CNAME records, One so Azure can verify the domain and the second to map the domain to the storage account.
First, add a new CNAME record with a name 'asverify.www' and with an address of the Primary endpoint URL we copied earlier with 'asverify.' at the start, eg. 'asverify.mynewwebsite.z33.web.core.windows.net'
Second, repeat that process but without the 'asverify'. So add a new CNAME record with the name 'www' and an address of the Primary endpoint URL, eg. 'mynewwebsite.z33.web.core.windows.net'
Your DNS records should look similar to the image below.
Now, go to your websites Storage Account within Azure and go to the Custom Domain tab. Here you will see there are two methods you can use to set up a custom domain. We have used the second method, CNAME validation.
In the domain name field, enter your domain, including www. and check the 'Use indirect CNAME validation' box.
Then click Save, and note the first couple of times will more than likely fail, as it can take some time for your DNS records to reflect the new settings we have just added. In our experience, it only takes around five minutes but your domain registrar will probably warn you that it can take up to 48 hours.
If it fails simply have a quick tea break and click save around 5 minutes later. It should then successfully save.
That's the custom domain set up, now all we need to do is configure a CDN to deliver the website.
Next, we will set up a CDN to deliver the website.