Lesson 1 of 3 App Service Domains, TLS and Networking

Mapping Custom Domains to App Service

This lesson explains the DNS records needed to map subdomains and root domains to an app and how domain ownership is verified.

Learning outcomes

After completing this lesson, you will be able to:

  • Identify the records needed for subdomains, root domains and wildcards.
  • Explain domain verification with the asuid TXT record.
  • Describe how to migrate a domain without downtime.

Records for subdomains and root domains

Custom domains are supported in the Shared tier and above, not in Free. On the app's Custom domains page, Add custom domain asks for the domain provider (App Service domain or all other providers), the TLS certificate option and the domain, then shows the records to create. The record type depends on whether the domain is a subdomain or the root (apex) domain.

DomainRecord to point trafficVerification record
Subdomain, such as www.contoso.comCNAME www to contoso.azurewebsites.net (or the unique default host name)TXT asuid.www with the custom domain verification ID
Root domain, such as contoso.comA record @ to the app's inbound IP addressTXT asuid with the custom domain verification ID
Wildcard, such as *.contoso.comCNAME * to the app's host nameTXT asuid with the verification ID

A CNAME record cannot exist at the zone apex, which is why the root domain uses an A record to the app's inbound IP address (shown on the Custom domains page). The custom domain verification ID is shown on the same page and is the same for all apps in a subscription.

Match the pairs

Which DNS record?

Exam skills 3.4.5

Match each record with the job it does when mapping contoso.com and www.contoso.com to an app.

Log in to try this activity Interactive activities are free with an account.

Validation and migration without downtime

After the records are created, App Service validates them and adds the domain; DNS changes can take time to propagate. The asuid TXT record proves ownership independently of where traffic points, so a domain that is still served by another host can be added and secured with a certificate before the A or CNAME record is changed. This is how a live site is migrated to App Service without downtime: verify with TXT, bind a certificate, then switch the traffic record.

If the zone is hosted in Azure DNS, an alias record can point the apex to the app (or to Front Door or Traffic Manager). Domains bought as App Service domains are hosted in Azure DNS and configured automatically. When an app is deleted, its CNAME should be removed too, to prevent subdomain takeover; unique default host names reduce this risk.

The following diagram shows, in the order they are created, the DNS records that map a custom domain to an App Service app without interrupting the current site.

Mapping contoso.com and www.contoso.com without interrupting the current site. TXT records asuid and asuid.www prove ownership first, so both domains can be added and certificates bound while DNS still points to the old site. Only then do an A record for the root, since the provider lacks ALIAS or ANAME, and a CNAME for www move traffic.
The scenario is illustrative.
Put in order

Migrating a live site

Exam skills 3.4.5 · 3.4.4

Arrange the steps that move a live domain to App Service without downtime.

Log in to try this activity Interactive activities are free with an account.
Worked example

Mapping both names

A company moves its site to the App Service app contoso-web. Both contoso.com and www.contoso.com must reach the app. The domain's DNS is hosted by a third-party provider that does not support alias or ANAME records. The current site must keep serving traffic until the new one is secured with TLS. Which records should you create, and in which order?

First create TXT records asuid and asuid.www with the verification ID, add both domains in App Service and bind certificates. Then create an A record for the root pointing to the app's inbound IP and a CNAME for www pointing to contoso-web.azurewebsites.net. A CNAME at the root is not allowed, and changing the traffic records first would send users to a site without a valid certificate.

Check yourself

Why can't a root domain such as contoso.com use a CNAME record to point to an app?

Show answer

CNAME records are not allowed at the zone apex, so the root uses an A record (or an alias record in Azure DNS).

Exam Tips

Remember for the exam

  • Subdomain: CNAME to the app; root domain: A record to the inbound IP.
  • Ownership is proved with an asuid TXT record containing the verification ID.
  • Use TXT verification to add and secure a domain before switching traffic.
  • The Free tier does not support custom domains.