Search code examples
azureazure-automationazure-vpn

Azure VPN Gateway: mantain client configuration valid across multiple VPN Gatway creation/deletion


I'm handling my VPN Gateway via Azure Automation script, totally executed on Azure and nothing on premises. The project is to activate the VPN gateway by launching an Azure PS Runbook (which creates and configure the object I need for my VPN) when I need it, and then remove the VPN Gateway with another Azure PS Runbook, to limit the cost of the VPN Gateway provisioning (I need it only in business hours/days, not 24/7).

So far so good, I can create my VPN Gatway when I want it, and I can download the client configuration to connect to my VNet.

The problem is that every time I destroy a VPN Gateway, the previous installed configuration on client it's not valid anymore for the next VPN Gateway: it can't connect anymore. I've tried by using a Standard static public IP address but it doesn't solve the problem. I see that the address used as server name on client changes every time (it's a string like 'azuregateway-9a430069....843cc.vpn.azure.com'). This is annoying since it means that I need to update the client configuration each time the VPN is destroyed, which means to log into Azure portal to download the configuration (very uncomfortable if I have more than one or two client).

Do Azure have a way to avoid this? I'm open to every solution, the best is to avoid completely the configuration update on client.

Maybe something like obtain the new VPN Gateway parameter and display it as result of the PS Runbook, or the worst case to obtain the *.zip file with the new configuration and store it somewhere I want (like a OneDrive).


Solution

  • I've contacted the Microsoft Tech Support and they told me that I can't do as I described in my question: once the Virtual Network Gateway resource is disposed, the link for that istance is deleted and the next allocation won't use the same link, because of datacenter allocation policies.