0

Is there a way to get an entire list of available IPs for an Application Gateway available in a subnet? The frontent IP is dynamically assigned, but I need it to be static. BUT the IPs needs to be randomly chosed from the subnet the same way dynmically assigning it does. I'm looking for a way to get it dynamically and set it statically. The FrontEndIP Configuration is created before the New-AzureRmApplicationGateway but the IP itself isn't assigned until the Gateway is being deployed, so I can grab it before running the New cmdlet.

Options: After deployment, I was thinking I COULD create a public IP to associate my Listeners to temporarily, save the Private IP address, and then recreate it statically and reassociate my Listeners. Then I would delete the public IP, but I don't want public to be in the picture.

Then I was thinking I could get the list of available IPs FOR the gateway and pick one from the list. But I'm not sure what restrictions I have to consider when it comes to the gateway. How can I recreate what Azure does during dynamic deployment?

Edit: Currently working on a script for this. Looks like the Test-AzureRMPrivateIPAddressAvailability is reporting that the Private IP address used by a gateway is still available..

Kathrine Stack
  • 189
  • 1
  • 2
  • 14
  • it will be the IPs in the CIDR range you used when you set it up. Which you should be able to find in your virtual network blade. Here is a link for some common powershell virtual network commands https://learn.microsoft.com/en-us/azure/virtual-machines/windows/ps-common-network-ref –  Dec 18 '18 at 18:08
  • I know it's in the range of the subnet, but I'm looking for a script or a how to get the ones that are actually available for the application gateway. And if I choose one, how do I check that all of the IPs the AppGW needs are available as well? – Kathrine Stack Dec 18 '18 at 18:29
  • In the portal, you can set a private IP for an application gateway and it will be a static IP address. – Kathrine Stack Dec 18 '18 at 21:47

1 Answers1

0

Actually, the public frontend IP for Application Gateway is assigned dynamically by Azure, however, we can specify a private IP in a subnet when you use private frontend IP for Application Gateway.

In this case, the key point is that this dedicated subnet where you Application Gateway resides can only contain Application Gateways, you can not deploy other resources like VMs in the subnet. So you just need to know the subnet IP address range instead of an available IPs list. Also, Azure reserves the first four and last IP address in each subnet for internal usage. You can use the rest IP address in the subnet. Read the APP GW FAQ.

Also, if you want to use New-AzureRmApplicationGatewayIPConfiguration to create an application gateway, the Azure Application Gateway require an empty subnet, get more details from SO answer.

Hope this will help.

Nancy
  • 26,865
  • 3
  • 18
  • 34
  • I've been able to create application gateways with my script in the same subnet, even if there is already and application gateway in the subnet. I guess my situation might be a little confusing. I'm trying to get what's available in the subnet, so I can choose the next available IP address to create a dynamic private IP address (one that is NOT already used by an application gateway in the subnet). I know I can statically create the IP configuration, and Azure will give me the next available, but I don't want my private IP to be static, nor do I want to hardcode a value in. – Kathrine Stack Dec 19 '18 at 18:48
  • I understand what you want to do, and it's ok if other application gateway existed in the subnet. Not sure if there is a way you can get an available IP address in a subnet with PowerShell. But it's easy to see the connected devices IP address in a subnet in the Azure portal, then you get the rest IP list in the subnet. – Nancy Dec 20 '18 at 02:41
  • @KathrineStack Is there any update on your side in this question? Is the reply helpful? – Nancy Dec 28 '18 at 11:03
  • It only showed the connected devices, not the IPs, but I was able to use the name of the connected devices. – Kathrine Stack Dec 28 '18 at 17:19