Map a custom domain to Azure App Service

This article explains how to map a custom domain name (like www.contoso.com) to your Azure App Service. This allows users to access your web app using a domain name they are familiar with, rather than the default .azurewebsites.net domain.

Prerequisites

Steps to Map a Custom Domain

1. Add the Custom Domain in Azure App Service

Navigate to your App Service resource in the Azure portal. In the left-hand menu, under Settings, select Custom domains.

Click on Add custom domain.

2. Validate Domain Ownership

Azure needs to verify that you own the custom domain you are trying to add. This is typically done using DNS records.

Example DNS Configuration (for www.contoso.com):


;; Record Type: CNAME
;; Host/Name: www
;; Value/Target: yourapp.azurewebsites.net

;; Record Type: TXT
;; Host/Name: asuid.www
;; Value/Target: YOUR_CUSTOM_DOMAIN_VERIFICATION_ID
            

Note: DNS propagation can take some time. If validation fails initially, wait a few minutes and try again. You can use online DNS lookup tools to check if your records have propagated.

3. Complete the Custom Domain Mapping

Once your DNS records have propagated and Azure can verify ownership, return to the Add custom domain panel in the Azure portal. Enter your full custom domain name (e.g., www.contoso.com) and click Validate.

If validation is successful, you will see green checkmarks next to the DNS record requirements. Click Add custom domain to finalize the mapping.

Binding SSL Certificates

After mapping your custom domain, it's crucial to secure it with an SSL/TLS certificate to enable HTTPS. This is a separate step:

  1. In the Custom domains blade, find your newly added custom domain.
  2. Click Add binding next to your custom domain.
  3. Choose your SSL certificate (either uploaded, purchased from Azure, or imported from Key Vault) and the SSL type (SNI SSL or IP SSL). SNI SSL is generally recommended and supported by most modern browsers.
  4. Click Add Binding.

Tip: For free SSL certificates, consider using the App Service Managed Certificates feature, which automatically provisions and renews certificates for your custom domains.

Troubleshooting

By following these steps, you can successfully map a custom domain to your Azure App Service, providing a professional and branded experience for your users.