Update your Azure DNS automatically when you have a dynamic public IP

Posted by Florent Appointaire on June 19, 2020
Tags: , ,

If you host website/application on a server, with a dynamic public IP, you can use services like DynDNS.

The problem is to maintain your public DNS with the last IP and, with Azure DNS, to create a @ record that points to a CName (Impossible at this time).

It’s why I created a PowerShell script to do it. To start, create an Azure Automation account and import modules Az.Accounts and Az.Dns.

Create a new runbook, and paste the following code:

The script will get the value of the public IP of your DynDns and compare it to the actual value of your Azure DNS record. If it’s not equal, the public IP of your router has changed, so, we update the value of the Azure DNS.

If the IP is the same, we don’t do anything:

Update DNS record

You can schedule the runbook to start it automatically, every X minutes.

Related materials:

Views All Time
Views Today
Return to all posts

Best Practices For Hybrid Cloud Deployment
How to Add Lifecycle Rule for a Cloud Storage Bucket