× {{alert.msg}} Never ask again
Receive New Tutorials
GET IT FREE

How to Set Up a Domain Name in Azure Cloud Service

– {{showDate(postTime)}}

domain name in azure

Microsoft Azure is one of the most popular cloud services available in the market. Azure generally provides a friendly sub-domain name for accessing your web application, which can be something like http://<mywebapp>.azurewebsites.net. You can also assign your custom domain name with the web service for better user visibility. The domain name can be purchased from any provider like GoDaddy, BigRock, etc.

Setting up a domain name in Azure requires some insight and knowledge. And this article will try to explain the steps required to set up a domain name in Azure cloud services. Also, we shall go through a few basic terms, in order to obtain a better understanding of the process.

Knowing DNS records

Most of us may be aware that Domain Name Service (DNS) is a procedure used for locating resources on the internet. Say, when you enter a certain web address in the browser’s address bar or click on a link, DNS is used for resolving the domain name into an IP address. Since the IP address can be very confusing, especially when you are trying to remember one, DNS names are preferred over them.

As such, the entire DNS system works on the basis of records. Records are basically the association of a certain name, say Google.com, with its IP address counterpart or another DNS. Web browsers first look up the name in the DNS and find the corresponding IP address value that is pointed to. If it points to another DNS then it is required to find the IP address and value again.  Ultimately, all resolutions result in an IP address.

Now, we shall learn a little about CNAME and A records.

Knowing CNAME and A records

CNAME and A records usually allow for the association of a domain name with a certain server or service. However, both of them are known to work in different ways. When using A records with Azure Cloud services, there are certain things to consider before using them.

  • CNAME: also known as Alias record, is known to map a certain domain name, like codementor.io or www.codementor.io, to a canonical domain name. The canonical domain name here would be [app].cloudapp.net for the application hosted on Microsoft Azure. Once it has been created, an alias is created by the CNAME for [app].cloudapp.net. The CNAME entry then automatically resolves to the IP address of the [app].cloudapp.net service, and even if your cloud service changes, you are not required to take action.
  • A record: An A record is known to map any domain, such as codementor.io or www.codementor.io, or even a wildcard domain like *.codementor.io to a certain IP address. Talking about this in terms of Azure Cloud Service, this is basically the virtual IP of the service. The main advantage of using A record over CNAME is that you require only one entry that makes use of a wildcard, like *.codementor.io, for handling requests of several sub-domains like mail.codementor.io, www.codementor.io or even login.codementor.io.

Adding a CNAME record for custom domain

In order to create a CNAME record, the first step is to add a new entry to the DNS table for the custom domain, making use of the tools offered by the registrar. Every registrar offers more of a similar but a slightly varying approach for specifying a CNAME record. However, the basic idea remains the same for all.

The first step is to find the .cloudapp.net domain name that has been assigned to your service. There are two ways to do that. One is to log in to the Azure Classic portal, select the service and then choose Dashboard. In the quick glance section, you will find the Site URL entry. The other way is to install and set up the Azure Powershell and then execute the following command:

Get-AzureDeployment -ServiceName yourservicename | Select Url  

Now, you must save the domain name that is returned by either of these two methods as you shall require it for the creation of the CNAME record.

The next step is to go to the DNS registrar’s site and visit the page for managing the DNS. Then look around for links that have been labeled as DNS, Domain Name, or Name Server Management. Following this step, you will need to look for the place where you can enter or choose the CNAME. You might need to select a record name from a drop down or visit the page for advanced settings. You will find the place with such names as CNAME, Subdomains, or Alias.

You are then required to provide the domain or subdomain alias for the CNAME, like that of www for the creation of an alias for www.customdomainname.com. If you wish to create an alias for the root domain, you can list it as ‘@’ symbol in the registrar’s DNS tools. Then, you are required to add a canonical host name, which will be the application’s cloudapp.net domain.

For example, if the hostname is www and the canonical domain is codementor.cloudapp.net, all traffic from www.codementor.io  will be forwarded to codementor.cloudapp.net by the CNAME record since that is the custom domain name for the application deployed.

As for the visitors, they will not see the true host, which is codementor.cloudapp.net, and it will be invisible to them.

Adding an A record for the custom domain

For the creation of an A record, you will first need to find out the virtual IP address of the cloud service. Then, using the tools offered by your registrar, you will need to add a new entry for the custom domain in the DNS table. Again, every registrar follows similar, albeit slightly different procedures for specifying A records.

The first step is to get the virtual IP address of the cloud portal. Log in to Azure’s Classic portal, choose the cloud service, and then select Dashboard. Under quick glance, you will find the entry for Virtual IP Address. You may also use Azure Powershell and you will need to install and configure it first. There you can execute the command –

get-azurevm -servicename yourservicename | get-azureendpoint -VM {$_.VM} | select Vip

If your connection has several endpoints for the cloud service, you will get several lines with IP addresses. However, all of them will display the same address. You will also need to save the IP address as you will require it when creating A record.

Now, log in to the registrar’s website and open the page for managing DNS. Again, you will need to find links with labels like DNS, Domain Name, or Name Server Management. Then you will need to select or enter the A record.

Next, you will need to enter the domain or subdomain that will be used for this A record. For example, select www for creating an alias for www.customdomain.com. If you are looking to create a wildcard entry for all the subdomains, you will need to enter ‘*’. This will cover all sub-domains like that of mail.customdomainname.com, login.customdomainname.com, and www.customdomainname.com. To create an A record for the root domain, you can list it as @ symbol in the DNS tools provided.

Finally, enter the IP address of the cloud service in the field given. This forms the association, i.e. of the domain entry used in the A record with the IP address.

If you have to create a wildcard entry for covering all subdomains, you will need to enter ‘*‘ as the subdomain.

Conclusion

Custom domain name setting is very important for every business. It is a unique way to represent your identity in the web world. A custom domain can be set up by an individual or a business, and there are multiple options available in the market for purchasing a domain name, hosting server, service providers, etc.

In this article, we have concentrated on setting up a domain name in the Azure Cloud service. Since custom domain names are very handy these days, one needs to know how they can be set up. The steps given above can easily help you in setting up a domain name in Azure Cloud services.

Other tutorials you might be interested in:


Author’s Bio:

domain name in azureKaushik Pal has more than 16 years of experience as a technical architect and software consultant in enterprise application and product development. He has interest in new technology and innovation, along with technical writing. His main focus is web architecture, web technologies, Java/J2EE, Open source, big data, cloud, and mobile technologies.You can find more of his work at www.techalpine.com and you can email him at techalpineit@gmail.com or kaushikkpal@gmail.com




Questions about this tutorial?  Get Live 1:1 help from DevOps experts!
Martin Foley
Martin Foley
5.0
CTO at Draft AI | #1 CodeMentor for Python, JS, Node, React for now - still working on the others ;)
I'm a Scotsman living in London. I have over 10 years experience coding. I have a first in Computer Science, worked at one of the top cyber...
Hire this Expert
Utkarsh Mishra
Utkarsh Mishra
5.0
Programmer since 2006. Lead technology for startups and enterprises.
I love building apps and working on cutting edge technologies, ensuring that they're ready for market in short development time. I also like to...
Hire this Expert
comments powered by Disqus