Configuring a custom domain for Azure website
Azure websites are distributed to the common azurewebsites.net domain. If your website title is contosoweb then it can be accessible at the URL contoso-web.azurewebsites.net. This might be acceptable during the development and testing. Once you are heading towards the release of your website, you will probably want to configure a custom domain for the website. You need to follow the below-listed steps to configure a custom domain.
- Get a custom domain from a domain registrar according to your preference.
- Use your domain registrar’s update DNS option to add DNS records for your domain.
- Connect this domain with Azure website.
Adding DNS records
You can add your DNS records using domain registrar which can be either a CNAME or A record. A record points a domain to a particular IP address. Speaking of Azure websites, this IP address is the IP address of the cluster of servers on which your website is functioning. Though this is not the IP address of a particular virtual machine. You can easily get your IP address for your A record from the management portal by simply clicking the domains and SSL part in the website blade. It will immediately open the SSL settings blade for your website as illustrated in Figure 1.
FIGURE 1 Locating the IP address to use for A recordsIf you are using an A record then you are required to add a CNAME record to confirm that you are owning the domain.This CNAME must be formatted as awverify.<yourdomain>.com and map to awverify.<your website name>.azurewebsites.net. Table 1 shows how the A and CNAME records are defined for the custom domain contoso.com.
TABLE 1 Example DNS records when using A records to configure a custom domain
The awverify CNAME can only be used when using an A record to configure a custom domain. If you are using a CNAME record, then your DNS records will probably show the custom domain and the Azure website URL. Also, it is likely to map subdomain. Below is the Table 2 showing an example of how a CNAME record can be defined for a custom domain contoso.com.
TABLE 2 Example DNS record when using CNAME records to configure a custom domain
Associating the custom domain with the website
When you confirm the CNAME records, the final step is to point the custom domain to your Azure website. You can use management portal to do so. Click on Manage Domains button and add the custom domain. Also, you can add the custom domain using the Set-AzureWebsite cmdlet as shown below
Set-AzureWebsite -Name "contoso-web" -HostNames @(www.contoso.com, "contoso.com")
Note: Custom domains are not supported in the free tier of Azure Websites.
This article is a part of 70-533 Implementing Microsoft Azure Infrastructure Solutions Prep course.
More Articles included in this course are
Practice Tests in this course are