How to Map Custom Domain to Azure Web App

In my previous blog, I had shown you how to create a azure web app with domain service enabled. if you notice the URL of the app, which is not at all user friendly, has domain name as “azurewebsites.net” and app name has some numeric figures attached to it (generally). It does not look good and gives rise to questions such as,

What If I Need To Map A Custom Domain Name?
What If I Need To Change The App Name?

In this blog, I will answer these questions. So, let’s get started.
One easy solution to the second question is that we should try and give a meaning full name while creating the app, but practically its difficult to get the name that we want because worldwide developers are using azure to create their apps. Another way of dealing with the challenge, which will solve both the issues, is using DNS records. We will use 2 types of DNS records.

Types Of DNS Records:

  • A records
  • CNAME records
These records are used to map custom domains to your azure web apps. DNS records are created by using the UI which your hosting partner provides. By using any one of these we can solve our purpose. For example “essenceoflearning.in” has a hosting on “Godaddy.com”, so to map the custom domain “essenceoflearning.in” to their azure web app, I have to open cpanel of my website provided by “Godaddy.com” and locate DNS setting to create the records.

Steps To Create A Records:

It maps custom domain to virtual IP address of Azure web app.
  • Go to azure portal, click on your web app in the “app service” menu.
  • Under the “Settings” option click on “Custom Domain”.
  • Note down the IP address shown on the screen.
  • Go to your website’s cpanel, under DNS setting select the domain you need to map and create A record wherein we will map essenceoflearning.in or a subdomain of essenceoflearning.in to the IP address.
  • Open the screen from where we got the IP address(i.e. from the azure portal) and click on “Add Hostname” to get “Add Hostname” screen.
  • Enter the hostname (www.essenceoflearning.in) and click on “validate”. It confirms that you own this hostname by checking the record you have put-in in the above steps.
  • Successful validation enables “Add Hostname” button, click on the button to complete the process.
The hostname just mapped might take time to populate under “custom domain” section. For me it took around 20 mins.

Steps To Create CName Records:

It maps custom domain to azure web app’s domain name. It is as good as giving an alias.
  • Go to azure portal and note down the web app’s URL. It is like “abc182017.azurewebsites.net”.
  • Go to your website’s cpanel, create a subdomain for example “app.essenceoflearning.in”.
  • Create CName record wherein we will map “app.essenceoflearning.in” to “abc182017.azurewebsites.net”.
  • Follow the steps 5-7 to add hostname, as shown to create A record.
Congratulations!!! you have given a user-friendly name to your azure app. I prefer to give CName because it holds good even if we change the pricing plan of our app, since changing the plan or restarting the web app might change the IP address of the app, in which case we need to change the IP address in the cpanel for A record.

This blog is also published on Voksedigital website

Comments

Popular posts from this blog

How to Handle Employee Hierarchy in Power BI