Configure Custom Domain for Web Application in Azure

This article is about creating a custom domain while deploying our web application in Azure App Service.

Creating WebApp in Azure

  1. ►Go to Azure portal.
  2. ►Click on create a resource and enter Webapp in the search bar.
  3. ►Click on create.
  4. ►Now create a web application with any runtime stack and location, but make sure to choose an SKU for the App Service plan, which supports custom domains!

Creating Custom Domain

  1. ►Go to the Web Application you have created.
  2. ►Go to the custom domains section in it.
  3. ►Click on Add a custom domain.
  4. ►Enter the name of the custom domain in the box and click on validate.
Adding Custom domain
Adding Custom Domain
  1. ►You can then see that you will need to have 2 DNS records, i.e., “A” record and “TXT” record, for the custom domain to get added to azure as below:
Ownership issue
Ownership Issue

There are two ways to solve the domain ownership issue.

Way 1:

Update the 2 DNS records, i.e., “A” and “TXT,” with those respective values in the DNS record settings of your domain provider.​

  1. ►Go to your domain provider, i.e., Godaddy or Freenom, etc.
  2. ►Go to your domains list in your account and go to the DNS Settings for the domain you entered in Azure.
  3. ►Click on Add DNS records in your domain provider portal and add two records, i.e., “A” and “TXT.”

Type: “A”. Name: “@”. Value:” PublicIP of the APP, i.e., the given IP.”

Type:” TXT”. Name:” asuid”. Value:” Given value in azure(above screenshot)”

So after you add the DNS records in your Domain Provider portal, it should look as below:

Adding DNS records
Add records
  1. ►After adding the DNS records, you can save the changes, wait for 2 minutes, and go back to Azure.
  2. ►After you go back to the validate page you are on before, you can click on validate again, and you will see that the domain ownership validation is also passed.

Way 2:

Create a DNS Zone in azure & store 2 DNS records in the DNS Zone and update your domain provider with Azure DNS Servers of your DNS Zone.​

  • ►Go to Azure and create a DNS zone with the name as your domain, i.e., if you are making a custom domain “example.com,” then the DNS Zone name must be the same, i.e., “example.com.”
  • ►After you created the DNS Zone with your custom domain name, you will see two records automatically created, i.e., one SOA and one NS.
  • ►SOA is the Start of Authority record, which contains information about zone and zone transfers, and the NS record is for saving the Nameservers.
  • ►Now add the “TXT” and “A” records you have added before in your domain provider portal here.
  • ►After adding the two records in the DNS Zone, copy the 4 Nameservers and paste those nameservers in your domain settings in your domain provider portal. [Ex: Freenom]
  • ►After you updated the domain provider portal with the Azure Nameservers, you can then go to the custom domain page and click on validate again.
  • ►Now you can see that the validation is passed and the domain gets added, and you will be able to use the custom domain.

PS: Azure also has the feature called “App Service Domain” in Custom domains through which you can buy the domains from Azure directly.

If you want to know how to link a Custom Domain to Azure AD, do check out this article :

https://www.linuxtrouble.com/2021/01/18/how-to-configure-custom-domain-for-azure-ad/

I also run a small youtube channel on some exciting topics, do look into it. 🙂

https://www.youtube.com/channel/UCBO2LHhj4-SYejcaE3YfuNg

With this, I conclude the article and will be back with more interesting articles soon 🙂

Leave a Reply

%d bloggers like this: