Configure a custom domain name in Azure App Service
Get going faster--use the NEW Azure guided walkthrough! It makes associating a custom domain name AND securing communication (SSL) with Azure Cloud Services or Azure App Service Web Apps a snap.
When you create a web app, Azure assigns it to a subdomain of azurewebsites.net. For example, if your web app is named contoso, the URL is contoso.azurewebsites.net. Azure also assigns a virtual IP address.
For a production web app, you probably want users to see a custom domain name. This article explains how to configure a custom domain with App Service Web Apps. (This article provides generic instructions for any domain registrar. The tabs at the top of this article link to some articles for specific registrars.)
This article is for Web Apps; for Cloud Services, see Configuring a Custom Domain Name in Azure.
For instructions on using Traffic Manager to load balance traffic to a web app, use the selector at the top of this article to select the Traffic Manager specific steps.
Custom domain names cannot be used with Free web app. You must configure your web app for Shared, Basic, or Standard mode, which may change how much you are billed for your subscription. See Web Apps Pricing Details for more information.
In this article:
Here are the general steps to configure a custom domain name:
- Reserve your domain name. This article does not cover that process. There are many domain registrars to choose from. When you sign up, their site will walk you through the process.
- Create DNS records that map the domain to your Azure web app.
- Add the domain name inside the Azure Portal.
Within this basic outline, there are specific cases to consider:
- Mapping your root domain. The root domain is the domain that you reserved with the domain registrar. For example, contoso.com.
- Mapping a subdomain. For example, blogs.contoso.com. You can map different subdomains to different web apps.
- Mapping a wildcard. For example, *.contoso.com. A wildcard entry applies to all subdomains of your domain.
Setting a custom domain name is only available for the Shared, Basic and Standard modes for Web Apps. Before switching a web app from the Free mode to the Shared, Basic or Standard mode, you must first remove spending caps in place for your Web Apps subscription.
For more information on the App Service plan modes, including how to change the mode of your site, see How to scale web apps.
DNS record types
The Domain Name System (DNS) uses data records to map domain names into IP addresses. There are several types of DNS records. For web apps, you’ll create either an A record or a CNAME record.
- An A (Address) record maps a domain name to an IP address.
- A CNAME (Canonical Name) record maps a domain name to another domain name. DNS uses the second name to look up the address. Users still see the first domain name in their browser. For example, you could map contoso.com to <yourwebapp>.azurewebsites.net.
If the IP address changes, a CNAME entry is still valid, whereas an A record must be updated. However, some domain registrars do not allow CNAME records for the root domain or for wildcard domains. In that case, you must use an A record.
The IP address may change if you delete and recreate your web app, or change the web app mode back to free.
Find the virtual IP address
Skip this step if you are creating a CNAME record. To create an A record, you need the virtual IP address of your web app. To get the IP address:
- In your browser, open the Azure Management Portal.
- Click the Browse option on the left side of the page.
- Click the Web Apps blade.
- Click the name of your web app.
- In the Essentials page, click All settings.
- Click Custom domains and SSL. The IP address is located towards the bottom of the page (just above the SSL Bindings section).
Create the DNS records
Log in to your domain registrar and use their tool to add an A record or CNAME record. Every registrar’s web app is slightly different, but here are some general guidelines.
- Find the page for managing DNS records. Look for links or areas of the site labeled Domain Name, DNS, or Name Server Management. Often the link can be found be viewing your account information, and then looking for a link such as My domains.
- When you find the management page, look for a link that lets you add or edit DNS records. This might be listed as a Zone file, DNS Records, or as an Advanced configuration link.
The page might list A records and CNAME records separately, or else provide a drop-down to select the record type. Also, it might use other names for the record types, such as IP Address record instead of A record, or Alias Record instead of CNAME record. Usually the registrar creates some records for you, so there may already be records for the root domain or common subdomains, such as www.
When you create or edit a record, the fields will let you map your domain name to an IP address (for A records) or another domain (for CNAME records). For a CNAME record, you will map from your custom domain to your azurewebsites.net subdomain.
In many registrar tools, you will just type the subdomain portion of your domain, not the entire domain name. Also, many tools use ‘@’ to mean the root domain. For example:
||IP Address or URL
Assuming the custom domain name is ‘contoso.com’, this would create the following records:
- contoso.com mapped to 127.0.0.1.
- www.contoso.com mapped to contoso.azurewebsites.net.
Create an “awverify” record (A records only)
If you create an A record, web app also requires a special CNAME record, which is used to verify that you own the domain you are attempting to use. This CNAME record must have the following form.
- If the A record maps the root domain or a wildcard domain: Create a CNAME record that maps from awverify.<yourdomain> to awverify.<yourwebappname>.azurewebsites.net. For example, if the A record is for contoso.com, create a CNAME record for awverify.contoso.com.
- If the A record maps a specific subdomain: Create a CNAME record that maps from awverify.<subdomain> to awverify.<yourwebappname>.azurewebsites.net. For example, if the A record is for blogs.contoso.com, create a CNAME record for awverify.blogs.contoso.com.
Visitors to your web app will not see the awverify subdomain; it’s only for Azure to verify your domain.
Enable the domain name on your web app
After the records for your domain name have propagated, you must associate them with your web app. Use the following steps to enable the domain names using your web browser.
It can take some time for CNAME records created in the previous steps to propagate through the DNS system. You cannot add the domain name of to your web app until the CNAME has propagated. If you are using an A record, you cannot add the A record domain name to your web app until the awverify CNAME record created in the previous step has propagated.
You can use a service such as http://www.digwebinterface.com/ to verify that the CNAME is available.
In your browser, open the Azure Portal.
In the Web Apps tab, click the name of your web app, select Settings, and then select Custom domains and SSL.
Use the DOMAIN NAMES text boxes to enter the domain names to associate with this web app.
Click the check mark in the lower right corner to save the domain name configuration.
Once configuration has completed, the custom domain name will be listed in the domain names section of the Custom domains and SSL blade for your web app.
At this point, you should be able to enter the custom domain name in your browser and see that it successfully takes you to your web app.
If you want to get started with Azure App Service before signing up for an Azure account, go to Try App Service, where you can immediately create a short-lived starter web app in App Service. No credit cards required; no commitments.