Tutorial: Map an existing custom DNS proper name to Azure App Service

Azure App Service provides a highly scalable, self-patching web hosting service. This tutorial shows y'all how to map an existing custom Domain Proper noun System (DNS) name to App Service. To drift a live site and its DNS domain name to App Service with no downtime, run across Migrate an active DNS name to Azure.

In this tutorial, you lot acquire how to:

  • Map a subdomain by using a CNAME tape.
  • Map a root domain by using an A record.
  • Map a wildcard domain by using a CNAME tape.
  • Redirect the default URL to a custom directory.

i. Prepare your environment

  • Create an App Service app, or utilise an app that you created for another tutorial. The web app'southward App Service programme must exist a paid tier and not Gratis (F1). See Scale upwardly an app to update the tier.
  • Make certain you can edit the DNS records for your custom domain. To edit DNS records, y'all need access to the DNS registry for your domain provider, such equally GoDaddy. For example, to add together DNS entries for contoso.com and www.contoso.com, yous must be able to configure the DNS settings for the contoso.com root domain. Your custom domains must be in a public DNS zone; private DNS zone is only supported on Internal Load Balancer (ILB) App Service Environment (ASE).
  • If you don't take a custom domain all the same, you lot tin can purchase an App Service domain.

two. Get a domain verification ID

Sign in to Azure

Open the Azure portal, and sign in with your Azure account.

Select the app in the Azure portal

  1. Search for and select App Services.

    Screenshot that shows selecting App Services.

  2. On the App Services page, select the proper noun of your Azure app.

    Screenshot showing portal navigation to an Azure app.

    You see the direction page of the App Service app.

    To add a custom domain to your app, you need to verify your ownership of the domain past adding a verification ID every bit a TXT record with your domain provider.

  3. In the left pane of your app page, select Custom domains.

  4. Copy the ID in the Custom Domain Verification ID box in the Custom Domains page for the next step.

    Screenshot that shows the ID in the Custom Domain Verification ID box.

    Warning

    Adding domain verification IDs to your custom domain can prevent dangling DNS entries and help to avoid subdomain takeovers. For custom domains yous previously configured without this verification ID, you should protect them from the aforementioned risk by calculation the verification ID to your DNS record. For more information on this mutual loftier-severity threat, run into Subdomain takeover.

  1. (A record merely) To map an A record, you need the app's external IP address. In the Custom domains page, copy the value of IP accost.

    Screenshot that shows portal navigation to an Azure app.

3. Create the DNS records

  1. Sign in to the website of your domain provider.

    You lot tin can use Azure DNS to manage DNS records for your domain and configure a custom DNS name for Azure App Service. For more information, run across Tutorial: Host your domain in Azure DNS.

  2. Detect the page for managing DNS records.

    Every domain provider has its own DNS records interface, and then consult the provider'southward documentation. Look for areas of the site labeled Domain Name, DNS, or Proper noun Server Direction.

    Often, yous can find the DNS records page by viewing your account information and and so looking for a link such as My domains. Go to that folio, then await for a link that'southward named something like Zone file, DNS Records, or Advanced configuration.

    The following screenshot is an example of a DNS records page:

    Screenshot that shows an example DNS records page.

  3. Select Add or the advisable widget to create a record.

  4. Select the type of tape to create and follow the instructions. You tin use either a CNAME tape or an A tape to map a custom DNS name to App Service.

DNS tape types

Scenario Example Recommended DNS record
Root domain contoso.com A record. Don't use the CNAME record for the root tape (for information, run across RFC 1912 Section 2.iv).
Subdomain www.contoso.com, my.contoso.com CNAME record. You tin can map a subdomain to the app'southward IP accost directly with an A record, only it's possible for the IP address to change. The CNAME maps to the app's default hostname instead, which is less susceptible to change.
Wildcard *.contoso.com CNAME record.
  • A
  • CNAME
  • Wildcard (CNAME)
  • For a root domain similar contoso.com, create 2 records according to the following tabular array:

    Record type Host Value Comments
    A @ IP address from Re-create the app's IP accost The domain mapping itself (@ typically represents the root domain).
    TXT asuid The verification ID you got earlier For root domain, App Service accesses asuid TXT record to verify your ownership of the custom domain

    Screenshot that shows a DNS records page.

  • To map a subdomain like www.contoso.com with an A tape instead of a recommended CNAME record, your A record and TXT record should look like the following table instead:

    Record type Host Value Comments
    A <subdomain> (for case, www) IP address from Copy the app's IP address
    TXT asuid.<subdomain> (for case, asuid.www) The verification ID y'all got earlier

    Screenshot that shows a DNS records subdomain page.

Note

For sure providers, such as GoDaddy, changes to DNS records don't become effective until you select a split up Salvage Changes link.

four. Enable the mapping in your app

After you create DNS records, you enable the mapping in your app.

  • A
  • CNAME
  • Wildcard (CNAME)
  1. In the left pane of the app page in the Azure portal, select Custom domains.

    Screenshot that shows the Custom domains menu.

  2. Select Add together custom domain.

    Screenshot that shows the Add host name item.

  3. Type the fully qualified domain name that yous configured the A tape for, such as contoso.com.

  4. Select Validate. The Add together custom domain page is shown.

  5. Make sure that Hostname tape type is set to A tape (case.com). Select Add custom domain.

    Screenshot that shows adding a DNS name to the app.

    Information technology might take some time for the new custom domain to be reflected in the app'due south Custom Domains page. Refresh the browser to update the information.

    Screenshot that shows adding an A record.

    If you missed a step or fabricated a typo somewhere before, a verification error appears at the lesser of the folio.

    Screenshot showing a verification error.

5. Test in a browser

Browse to the DNS names that you configured earlier.

Screenshot that shows navigation to an Azure app.

If you receive an HTTP 404 (Non Institute) error when you scan to the URL of your custom domain, the 2 most common causes are:

  • The custom domain configured is missing an A record or a CNAME record. Y'all may have deleted the DNS record after yous've enabled the mapping in your app. Check if the DNS records are properly configured using an online DNS lookup tool.
  • The browser client has buried the former IP address of your domain. Articulate the enshroud, and test DNS resolution once more. On a Windows automobile, you clear the cache with ipconfig /flushdns.

(Optional) Automate with scripts

You tin automate management of custom domains with scripts by using the Azure CLI or Azure PowerShell.

  • Azure CLI
  • PowerShell

The following command adds a configured custom DNS name to an App Service app.

                  az webapp config hostname add \     --webapp-name <app-proper noun> \     --resource-group <resource_group_name> \     --hostname <fully_qualified_domain_name>                                  

For more data, see Map a custom domain to a spider web app.

Side by side steps