Creating a Custom Domain for WebApp in Azure(Azure App Service)
This article is about how to create a custom domain when we are deploying our web application in Azure App Service .
I will clearly explain the different methods to create and configure our custom domain in Azure App Service. So lets get into it!
Creating WebApp in Azure
- Go to Azure portal
- Click on create a resource and enter Webapp in the search bar.
- Click on create and 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
- Go to the Web Application you have created.
- Go to the custom domains section in it.
- Click on Add a custom domain
- Enter the name of the custom domain in the box and click on validate.
5.After you enter the custom domain and click on validate 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:
6.So there are 2 ways to solve the domain ownership issue
→Update the 2 DNS records i.e “A” and “TXT” with those respective values in the DNS record settings of your domain provider.
→Create a DNS Zone in azure and store the two DNS records in the DNS Zone and update your domain provider with Azure DNS Servers of your DNS Zone.
We will take a look in both of the ways:
→Go to your domain provider i.e Godaddy or Freenom etc..
→Go to your domains list in your account and go to the DNS Settings for the domain you entered in Azure.
→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:
→After the DNS records are added , you can save the changes and wait for 2 minutes and can go back to Azure.
→After you go back to the validate page which you are on before , you can click on validate again and you will see that the domain ownership validation is also passed.
- Go to Azure and create a DNS Zone with the name as your domain i.e if you are creating 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 that there are 2 records automatically created i.e one SOA and one NS.
- SOA is basically the Start of Authority record which contains information about zone and zone transfers and NS record is for saving the Nameservers.
- Now add the “TXT” and “A” record you have added before in your domain provider portal here.
- After you added the two records in the DNS Zone , copy the 4 Nameservers and paste those nameservers in your domain settings in your domain provider portal.
- 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 custom 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 i.e you can buy the domains from the Azure directly so the setting up process can be ignored in that case.
This concludes the article , I will be back with more interesting articles soon :)