Moving to Azure DNS

As an experiment, and for experience, I am moving away from the registrar-provided DNS over to Azure DNS.

From registrar DNS to Azure DNS

I don’t have a shitload of records, but more than I want to type in manually. Thankfully the registrar allows exporting the zone file. So I went ahead and tried to upload that as-is to Azure DNS. This failed, as it didn’t contain any SOA record. I suspect that’s due to some “magic” on the somewhat basic web interface.

To see what was expected, I downloaded the default zone for Azure DNS. Going the path of least resistance, I just copied over my records to the zone file from Azure. After those were appended to the file, the Azure ate the import file without issues.

$ export default dns zone from azure
az network dns zone export -g rg-m15n -n m15n.no -f azure_dns_export

Importing the DNS zone file to Azure DNS

az network dns zone import -g rg-m15n -n m15n.no -f m15n.no.zone
In the future, zone name will be case insensitive.
== BEGINNING ZONE IMPORT: m15n.no ==

(1/21) Imported 1 records of type 'soa' and name '@'
(21/21) Imported 1 records of type 'txt' and name '_gitlab-pages-verification-code.www'

== 21/21 RECORDS IMPORTED SUCCESSFULLY: 'm15n.no' ==

Remove records no longer needed

It’s possible Azure could do this automatically when the custom domain to removed from the statis web app (before it’s re-added with the apex domain).

Turns out, there’s no output when removing records, only when adding/modifying them? There is however an error if trying to remove a record that does not exist.

$ az network dns record-set cname remove-record \
  --resource-group rg-m15n \
  --zone-name m15n.no \
  --record-set-name az \
  --cname kind-pond-0021e7203.1.azurestaticapps.net. \
  -o table
$ az network dns record-set cname remove-record \
  --resource-group rg-m15n \
  --zone-name m15n.no \
  --record-set-name www.az \
  --cname kind-pond-0021e7203.1.azurestaticapps.net. \
  -o table

It was a one-liner, but that looks pretty bad in markdown codeblocks.

Edit custom domain for static web app

Initially, I used the az.m15n.no as a custom domain for Azure, while I now want to use m15n.no for it. As such, changes are needed.

I didn’t see a way to do that with the cli, so I removed the old ones in the web interface and added the new one. No issues, though Azure isn’t the best at telling you when it’s completed. The text changes, but the loading dots on the top stayed, and there’s no green checkbox or such. In any case, worked wonders, and the process should now be completed.

Conclusion

I suppose the main difference is that I can now add any new subdomains easily with the cli. Unfortunately there doesn’t seem to be any free tier for DNS, so we’ll have to wait and see how that goes. Alerts are configured.

Rather than move everything to Azure, I will still be keeping the GitLab repo, and just pushing to both. More or less because I feel like it.