This article is about creating a custom domain while deploying our web application in Azure App Service.
Creating WebApp in Azure
- ►Go to Azure portal.
- ►Click on create a resource and enter Webapp in the search bar.
- ►Click on create.
- ►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
- ►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.
- ►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:
There are two 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.
- ►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 adding the DNS records, you can save the changes, wait for 2 minutes, and go back to Azure.
- ►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.
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 :
I also run a small youtube channel on some exciting topics, do look into it. 🙂
With this, I conclude the article and will be back with more interesting articles soon 🙂