Azure Automation: Update VPN Local Network Gateway

In a previous post we set up a Site to Site VPN in ARM to a lab environment that is sitting behind router with a dynamic IP. Just a reminder this isn’t supported for production usages, but this is very useful for your own dev/test environments.

If you have a dynamic IP that can change from time to time, this Azure Automation script can help keep the IP address of your Local Network Gateway Device updated.

Just set it to run on a schedule to suit your needs and your VPN connection will stay connected. After the Local Network Gateway has been updated the VPN will automatically re-connect.

Thanks to the following link for a method to resolve the DNS using Google DNS API. I came across the same issue in the thread trying to use Resolve-DnsName.

Just substitute your own values and create your automation artefacts:

  • tenantId
  • subscriptionId
  • dynamicDnsHostname