Microsoft Learn

Tutorial: Configure a custom domain and SSL certificate in Azure App Service

This tutorial shows you how to map a custom domain to your Azure App Service app and secure it with an SSL/TLS certificate. Mapping a custom domain is a common requirement for production apps, and securing it with SSL ensures your users' data is encrypted.

Prerequisites

Step 1: Map Your Custom Domain to App Service

Before you can configure SSL, you need to prove ownership of your custom domain by mapping it to your App Service app.

1

Add a Custom Domain Record

In your DNS provider's management portal, create a CNAME record for your subdomain (e.g., www) pointing to your App Service app's default domain name (e.g., your-app-name.azurewebsites.net).

For a root domain (e.g., yourdomain.com), you'll typically create an A record pointing to the IP address of your App Service app and a TXT record for verification. You can find the IP address and the required TXT record value in the Azure portal.

Example CNAME record:

Type: CNAME
Name: www
Value: your-app-name.azurewebsites.net

Example A record (for root domain):

Type: A
Name: @
Value: [App Service IP Address]

Example TXT record (for root domain verification):

Type: TXT
Name: @
Value: [Verification ID from Azure Portal]
2

Validate and Add Domain in Azure Portal

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

Click Add custom domain.

Enter your custom domain name (e.g., www.yourdomain.com) and click Validate.

If the DNS records are set up correctly, Azure will validate your domain. Click Add custom domain again to add it to your app.

DNS propagation can take some time (up to 48 hours, though usually much faster). If validation fails, wait a while and try again.

Step 2: Secure Your Custom Domain with an SSL Certificate

Once your custom domain is mapped, you can secure it. You have two main options:

Option A: Upload Your Own SSL Certificate

1

Prepare Your Certificate

Ensure your SSL certificate is in .pfx format and includes the private key.

2

Upload the Certificate

In the Azure portal, navigate to your App Service app, and select TLS/SSL settings from the left-hand menu.

Go to the Private Key Certificates (.pfx) tab.

Click Upload Certificate. Browse for your .pfx file, enter your certificate password, and click Upload.

3

Bind the Certificate to Your Custom Domain

Still in TLS/SSL settings, go to the Custom domains tab.

Find your custom domain in the list and click the Add binding link next to it.

In the "Add TLS/SSL Binding" pane:

  • Select your custom domain.
  • Select the certificate you just uploaded from the "Private Certificate Thumbprint" dropdown.
  • Choose the TLS/SSL Type (e.g., SNI SSL is common and usually sufficient).

Click Add Binding.

Option B: Create a Free App Service Managed Certificate

1

Navigate to TLS/SSL Settings

In the Azure portal, navigate to your App Service app, and select TLS/SSL settings from the left-hand menu.

Go to the Private Key Certificates (.pfx) tab.

Click Create App Service Managed Certificate.

2

Select Domain and Create

Choose your custom domain from the dropdown list.

Click Create.

Azure will automatically provision, manage, and renew the certificate for you.

3

Bind the Certificate

After the managed certificate is created (this may take a few minutes), go back to the Custom domains tab within TLS/SSL settings.

Click Add binding for your custom domain.

Select your custom domain, choose the newly created App Service Managed Certificate from the "Private Certificate Thumbprint" dropdown, select SNI SSL as the TLS/SSL Type, and click Add Binding.

App Service Managed Certificates are free and automatically renew. They are ideal for most use cases. You can only create one managed certificate per custom domain.

Step 3: Enforce HTTPS

To ensure all traffic to your custom domain is secure, enforce HTTPS.

1

Enable HTTPS Only

In the Azure portal, navigate to your App Service app and select TLS/SSL settings.

Under the Bindings section (or navigate to the Custom domains tab), find the HTTPS Only toggle.

Set HTTPS Only to On.

Your custom domain is now configured, secured with an SSL certificate, and all traffic is being redirected to HTTPS. You can test this by navigating to https://yourdomain.com in your browser.

For more advanced scenarios, such as using your own wildcard certificates or certificates with enhanced validation, refer to the official Azure App Service documentation.