Creating DNS Records for a Web App

I have to tell you the truth. I have a lot of fun with my work. I really do. I love figuring things out. I love challenges and learning new things. I don’t have any problems feeling uncomfortable.

This feels like a super fun game.

Going back to our experiments, this time we’ll create DNS records in Azure DNS Zone for that nice Django web app we deployed in the last article so we can access it via a custom domain. Let’s go!

What is DNS?

The Domain Name System (DNS) is the phonebook of the Internet. Us humans access the information available online through domain names. Those are the names we type in the browser’s window. The browser, however, interacts with the Internet through Internet Protocol (IP) addresses. These are sequences of numbers that aren’t that convenient to memorize. Each device connected to the Internet has a unique IP address, which other machines use to find the device. The job of DNS is to translate domain names into IP addresses so browsers can fetch and load Internet resources.

DNS Query

There are 4 steps in resolving a query for a web address. This process involves 4 servers: the DNS recursive resolver (also known as DNS recursor), the root server , the top level domain (TLD) nameserver, and the authoritative nameserver.

When you type a web address in your browser, if it doesn’t already know the IP address associated with the URL you typed, it sends a request to the DNS recursor, the first stop in a DNS query. It will either respond to the query with cached data or send the request to a root nameserver. The root nameserver responds to this request by directing the recursive resolver to a TLD nameserver, based on the extension of that domain (.com, .net, .org, etc.). A TLD nameserver maintains information for all the domain names that share a common extension.

When the recursive resolver receives the response from the TLD nameserver, that response will direct the resolver to an authoritative nameserver. The authoritative nameserver contains information specific to the domain name it serves, and it can provide the recursive resolver with the IP address of that server found in the DNS A record. If the domain has a CNAME record (alias), it will provide the recursive resolver with an alias domain. More on DNS records later.

Azure DNS

Azure DNS is a hosting service for DNS domains that uses Microsoft infrastructure. You can manage your DNS records by using the same credentials, APIs, tools and billing as your other Azure services. DNS domains in Azure DNS are hosted on Azure’s global network of DNS name servers. The domains and records can be managed by using the Azure portal, Azure PowerShell or the Azure CLI.

Now the Cool Stuff!

I read somewhere that you should by the domain name with your kid’s names, for the future. I did just that, and bought the luka-j.com domain. I like this name. It sounds cool, doesn’t it. That’s the domain I’m going to use for this lab. It’d be a good idea if you had access to your own domain name, one you have control over.

For this lab, I’ll configure Azure DNS to host my own custom domain for my web app. My app will point to http://www.luka-j.com and luka-j.com.

We’ll need to create three records:

  • An “A” record, pointing to luka-j.com
  • A “TXT” record, used for verification
  • A “CNAME” record, for the www name that points to the A record

DNS Records

Before we move on, let’s develop more on DNS Records.

DNS records, or zone files, are instructions that live in an authoritative nameserver and provide information about a domain, including what IP address is associated with that domain and how to handle requests for that domain. They consist of text files written in what is known as DNS syntax. All DNS records have a ‘TTL’, which stands for time-to-live, and indicates how often a DNS server will refresh that record.

Creating a DNS Zone

Let’s create a DNS Zone to host all our DNS records. We’ll use the Azure Portal.

Click on Create a resource, and search for DNS Zone. It should look like this.

I named my resource luka-j.com, like the domain.

Once the DNS Zone is created, let’s navigate to it, and create the DNS records.

Creating the DNS Records

As we mentioned, the A record is used to map a domain name to its IP address. In our case, we’ll need to look for the web app’s IP address. We’ll find it under Custom domains, in the App Services navigation pane.

Back in the DNS Zone resource, we’ll click on + Record set. We populate the fields like this to create the A record. The @ under Name represents the root domain.

Now we’ll create the TXT record. Again, click on + Record set. App Services will use this record to verify that we are actually the owners of this custom domain.

Finally, we’ll create the CNAME record.

This is how I did it, filling the original App Services URL in the Alias field. In the end, it worked, but I could have put luka-j.com, or maybe just leave it blank. That’s something to be investigated.

Let’s now verify the records by querying the domains using nslookup.

Adding the Custom Names to the Web App

Back to App Service resource, we’ll click on Custom domains on the left navigation pane, then on Add custom domain.

I did this for http://www.luka-j.com and for luka-j.com. For the luka-j.com, however, it gave me an error. It couldn’t validate the domain. I then had to update the TXT record. I first had put @ on the name field, but the error message when trying to validate the domain told me to populate the name and value fields with what you see below. It worked!

This is the app running on both URLs.

Is this article too long? How did you like it? Please let me know. My goal is to always be improving.

These days I’ve been experimenting with Azure Active Directory. That’s gonna be the subject of my next article.

See you!

One thought on “Creating DNS Records for a Web App

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s