Click here to Skip to main content
15,306,017 members
Articles / Hosted Services / Azure
Posted 22 Dec 2020

Tagged as


3 bookmarked

How to Configure a Secured Custom Domain on an Azure Function or Website

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
22 Dec 2020CPOL2 min read
Tutorial to map a naked domain on an Azure resource
I wanted to create this tutorial for a long time. How to map a naked domain on an Azure resource. It looks so complicated, but once you know what to do, it's kind of simple in fact. In this post, I will share the three simple steps to do exactly this.

This article is a sponsored article. Articles such as these are intended to provide you with information on products and services that we consider useful and of value to developers

Step 1: Add Custom Domain

The first step is to map a domain on the application. The method I will explain uses a "www" domain (example, To map directly a naked domain (example,, you would need to buy a wildcard certificate. However, I will show you in step three how to walk around this issue by using DNS rules.

From the Azure portal, open the Azure Function or App Service. From the left menu, search for "custom", click the Custom domains option. In this panel, click the button Add custom domain, and enter your www domain.

Image 1

Click the Validate button and follow the instruction to make the connection between the App Service and your domain provider.

Step 2: Adding a Certificate

Now that your custom domain is mapped, let's fix the "not secure" warning by adding a certificate. From the Azure portal return in the App blade. Repeat the previous search for "custom", and select the option TLS/SSL settings. Click the Private Key Certificates, and the Create App Service Managed Certificate button. Select the domain previously added and save. It will take a few moments to create the certificate.

Image 2

Go back in the Custom domains blade and click the Add binding button. Select the domain and certificate, don't forget to select the SNI SSL option and click the Add Binding button.

Image 3

Step 3: Create the DNS Rules

Create an account in and add a site for your domain. We will need to customize the DNS and create some Page Rules.

Image 4

On the, note the 2 nameservers addresses. Go to the origin name provider (in my case, godaddy) and replace the names of the nameservers with the value found on cloudflare.

Image 5

Create a rule that will redirect all the incoming traffic from the naked-domain to www.domain. On the option on the top, click the Pages Rules (B). Then click the Button Create Page Rule.

Image 6

In the field for If the URL matches: enter the naked-domain follow by /*. That will match everything coming from that URL.

For the settings, select Forwarding URL and 301- Permanent Redirect. Then the destination URL should be https://www. with your domain and /$1.



  • 22nd December, 2020: Initial version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Frank Boucher
Canada Canada
No Biography provided

Comments and Discussions

QuestionNeed Cloudflare? Pin
Jo-Anne23-Dec-20 9:33
MemberJo-Anne23-Dec-20 9:33 
AnswerRe: Need Cloudflare? Pin
Frank Boucher6-Jan-21 9:13
sponsorFrank Boucher6-Jan-21 9:13 
I know you can forward at GoDaddy but I'm not sure if there are the "rules". I will need to test that. Good question!

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.