Find a free IP address in Azure

This post is also available in Deutsch

Whether with automated deployment or when creating a load balancer in Azure. Finding a free IP address is unfortunately not an easy task with the existing Cmdlets.

Test-AzureRmPrivateIPAddressAvailability

A popular way to archive that is to use the Cmdlet ‘Test-AzureRmPrivateIPAddressAvailability’. It returns the value TRUE or FALSE when specifying the network and an IP address. Some people now loop through every network address in a subnet until a free IP address is confirmed by TRUE.

That’s not only slow, it’s unnecessary. The Cmdlet additionally returns a property “AvailableIPAddresses”. This property contains the next 5 free IP addresses.

Get-AzSRFreeIPAddress

However, this Cmdlet has one shortcoming. Only the specified subnet is checked. With my Cmdlet ‘Get-AzSRFreeIPAddress’ you not only get the free IP addresses from a subnet, but if you want and the parameter Subnet is not specified, you get all free IP addresses from every available subnets.

Of course you can also get only a certain number of IP addresses. With the parameter ‘-First’ the desired number can be defined.

This entry was posted in Uncategorized, Uncategorized on by .

About

Ich arbeite als IT Consultant bei Aequitas Integration und habe einen Fokus auf die Microsoft Enterprise Produktpalette. Jedoch beschäftige ich mich schon lange auch mit Linux und finde auch die unteren OSI Schichten interessant.