Previously

In the previous article I talked about moving an App Service to another App Service Plan to be able to support Custom Domains.

Move an App Service to another App Service Plan

Intro & Goal

So, I have my blog website running in an Azure App Service at 'https://random-awesome-memory.azurewebsites.net/'. But that doesn't cut it anymore for me. I want a dedicated domain of my own choosing to attach to my website. Personally, I think it looks better and has a more professional feel to it.

App Service Documentation

Check Tutorial: Map an existing custom DNS name to Azure App Service on how to do this thoroughly and maybe in a different way

Buy a domain name

The first step you need to take is buy/register a domain name. In case you have already acquired one, you can skip this step. You can do this with any Domain Provider, and there's a lot of them. Check if the domain name you wish to register is still available, hopefully it is. And then just buy it. I never buy a domain name unless I'm absolutely sure that I'm going to use it for a personal or professional project.

You can also buy a domain name in Azure.

Azure App Service Documentation

Check Buy a custom domain name for Azure App Service

Do realize that when you do this in Azure, you have to do this via App Service Domain, which also brings an extra cost.

Azure App Service Pricing

Check App Service Domain Pricing for more details

Next to domain registration in Azure, this also makes use of Azure DNS to host the domains, so extra cost for that is taken into account as well.

Azure DNS Pricing

Check Host your Domain Name System (DNS) domain in Azure for more details

I'm not going to do this via Azure beacuase the cost is a little too high for me. I've been buying my domain names via the same Domain Provider for years now. And I'm not going to do this any differently for now. The downside of the way I'm doing it now is that I'm dependant on an external platform. If you do this in Azure, it's all centralized in one place and it's easier to maintain. But for now, I'm willing to sacrifice the ease of use in exchange for the low cost.

Make sure that your App Service Plan is at least of type D1 Shared or higher. The Free Plan doesn't support Custom Domain Names. I have already done that in the previous article so off we go.

Get a hold of the App Service Custom Domain Verification Id

Well that's a mouth full. This ID is required to configure your DNS settings and to verify domain ownership. But we'll come to that in a second.

  1. In Azure, navigate to your App Service, to me, that's my random-awesome-memory App Service.
  2. In the side menu pane, click on Custom Domains page under the section Settings. There you will find the Custom Domain Verification Id. Copy it to your clip board.

Azure Security Fundamentals Documentation

Check Prevent dangling DNS entries and avoid subdomain takeover for more information on how this Id can prevent subdomain takeovers

Create the DNS records

The next step is to configure your DNS records. Beacuase I have registered my domain name at my Domain Provider, I need to configure my DNS settings there. I can easily access the DNS Management on their website. I added the DNS record using a CNAME and mapped it to the default hostname, being 'random-awesome-memory.azurewebsites.net'.

App Service Documentation

Check DNS record types for more details

  1. So, for the CNAME record I use 'random-awesome-memory.azurewebsites.net.'. Mind the dot in the end. I don't know if this is default or related to my Domain Provider but I had to add that in the end or it didn't work.
  2. And I add another record of type TXT with the Custom Domain Verification ID of the App Service, which we fetched earlier. Then save the changes and wait.
It might take some time for the changes to take effect depending on the Domain Provider.

Add the Custom Domain in the App Service

The following steps were taken:

  1. Navigate to the Custom Domains page of your App Service again. Click Add Custom Domain.
  2. Add the fully qualified Custom Domain name, which in my case is 'www.random-awesome-memory.be'. Click Validate.
  3. The hostname record type has to be set to CNAME, as described and configured earlier.
  4. If the DNS settings were correctly configured before, the CNAME will be filled in with the same value that was set into the DNS settings. In this case it was 'random-awesome-memory.azurewebsites.net'.
  5. When the validation checks succeed, meaning the hostname is available and the domain ownership has been verified, click Add Custom Domain.
  6. And voila, the new url to your website should work.

In case you were too fast, trying to map the Custom Domain in the App Service, right after configuring the DNS settings, you might get some validation errors. Be sure to try again later in case the DNS changes haven't been registered yet.

After adding the Custom Domain, you will probably see a warning message saying:

You have custom domains that are not secured and will cause browser warnings/errors when accessed over https. Click on "Add binding" to secure your custom domains..
The reason for this is beacuase the domain hasn't been secured with a certificate yet. Uncheck the HTTPS Only option to make sure the traffic isn't redirected to HTTPS for now. This isn't a disaster but surely a best practice for any website.

The result of course is this:

Since it's a simple website and you don't need to give my your bank account credentials anywhere, I'll leave it the way it is for now. This will be addressed later.

Conclusion

Yet another process made easy with Azure. I do recognize the fact that using the App Service Domain would be easier and centralized in Azure. But instead I chose for a regular Domain Provider. Although my Domain Provider recently introduced an extra cost to Manager the DNS settings per domain name, it clearly doesn't come near the cost of the Azure App Service Domain and Azure DNS solutions.

Documentation Reference

Next

In the next article I'm going to discuss how to add a TLS certificate to the website.

Secure the domain using a TLS certificate