1

I'm trying to redploy an arm template to create a vgw and vnet. I notice that everytime I deploy my arm template my virtual network gateway always gets a new IP address regardsless if specific an IP. Which begs the question.

If I delete the public ip address resource is there anyway I can get that same address back once it has been freed up?

Note: I also tried change the type from static to dynamic and Azure complains it wants a load balancer assigned to it but I doubt that will affect.

Sample ARM template

"resources" : [
     {
            "type": "Microsoft.Network/publicIPAddresses",
            "apiVersion": "2019-09-01",
            "name": "[parameters('publicIPAddresses_VGW1_public_ip_name')]",
            "location": "canadacentral",
            "sku": {
                "name": "Basic"
            },
            "properties": {
                "ipAddress": "20.43.0.134",
                "publicIPAddressVersion": "IPv4",
                "publicIPAllocationMethod": "Dynamic",
                "idleTimeoutInMinutes": 4,
                "ipTags": []
            }
        }]

Sam Cogan
  • 38,158
  • 6
  • 77
  • 113

1 Answers1

2

Your issue is this line:

         "publicIPAllocationMethod": "Dynamic",

Because you have it set to dynamic it will get recreated each time you deploy. Switch this value to "static" and you will retain it.

Sam Cogan
  • 38,158
  • 6
  • 77
  • 113