Search code examples
azureazure-virtual-network

For a given Azure subnet how to find the first two available private IPs?


I have subnet that shows 3 available IPs as below. Is there a quick way to fetch the first 2 available IPs?

enter image description here


Solution

  • For a given Azure subnet how to find the first two available private IPs?

    I tried in my environment and got the below results:

    In my environment, I have 58 available IP addresses.

    enter image description here

    You can use the azure cli command below to fetch the first 2 available Ip addresses.

    Command:

    az network vnet subnet list-available-ips --resource-group <your-resource-grp> --vnet-name vnet01 -n subnet-1 --query [0:2] 
    

    Output:

    [
      "10.1.6.5",
      "10.1.6.6"
    ]
    

    enter image description here

    Reference:

    az network vnet subnet | Microsoft Learn