Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect output of the az network vnet subnet list-available-ips command #23997

Open
subhasishdc opened this issue Sep 24, 2022 · 21 comments
Open
Labels
Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue points to a problem in the management-plane of the library. needs-team-attention This issue needs attention from Azure service team or SDK team Network az network vnet/lb/nic/dns/etc... question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.
Milestone

Comments

@subhasishdc
Copy link
Contributor

subhasishdc commented Sep 24, 2022

I was checking the number of available ip addresses in the subnet where an application gateway is deployed using this:

schowdhu@schowdhu-mn1 ~ % az network vnet subnet list-available-ips --resource-group aag-rg --vnet-name aagVnet -n AAG1Subnet This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus [ "10.0.36.244", "10.0.36.245", "10.0.36.246", "10.0.36.247", "10.0.36.248" ]

Following shows my subnet size and the app gw instances deployed.

[schowdhu@schowdhu-ld3 ~]$ az network vnet subnet show -g aag-rg -n AAG1Subnet --vnet-name aagVnet | jq '.addressPrefix' "10.0.36.240/28"

[schowdhu@schowdhu-ld3 ~]$ az network application-gateway list -g aag-rg | jq '.[] | .name,.sku,.operationalState' "aag01" { "capacity": 8, "name": "Standard_Medium", "tier": "Standard" } "Running"

Based on the app gw documentation (https://docs.microsoft.com/en-us/azure/application-gateway/configuration-infrastructure#size-of-the-subnet), app gw uses one private IP address per instance, plus another private IP address if a private front-end IP is configured. Azure also reserves five IP addresses in each subnet for internal use: the first four and the last IP addresses. Taking the above example for reference, total available ip addresses in the subnet 10.0.36.240/28 is 16. Azure uses 5 ip addresses and app gw has 8 instances. There should be only 3 ip addresses remaining. However, the az network vnet subnet list-available-ips command shown above shows 5 ip addresses available.

https://learn.microsoft.com/en-us/cli/azure/network/vnet/subnet?view=azure-cli-latest#az-network-vnet-subnet-list-available-ips -- This is the example in the documentation. It mentions "List some available ips in the subnet.". Does it mean it shows free ip addresses which are not used yet in the subnet or just it just display a few ip addresses belonging to the subnet irrespective of weather they are being used or not.

Am I missing something here or is there an issue with what the command is showing.

@ghost ghost added customer-reported Issues that are reported by GitHub users external to the Azure organization. Network az network vnet/lb/nic/dns/etc... labels Sep 24, 2022
@ghost ghost added this to the Backlog milestone Sep 24, 2022
@ghost ghost assigned necusjz Sep 24, 2022
@ghost ghost added the Auto-Assign Auto assign by bot label Sep 24, 2022
@yonzhan
Copy link
Collaborator

yonzhan commented Sep 25, 2022

@necusjz for awareness

@yonzhan yonzhan added Azure CLI Team The command of the issue is owned by Azure CLI team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 25, 2022
@RakeshMohanMSFT
Copy link
Contributor

#13853 can you take a look at this?

@yonzhan yonzhan added the CXP Attention This issue is handled by CXP team. label Sep 25, 2022
@ghost
Copy link

ghost commented Sep 25, 2022

Thank you for your feedback. This has been routed to the support team for assistance.

@subhasishdc
Copy link
Contributor Author

@RakeshMohanMSFT : Thank you for the link. This leads me to another question. Does the option list-available-ips list free available ip addresses in the subnet or just any IP address ( irrespective of weather its being used or not). If its the first option, then the issue I mentioned above holds true and needs to be investigated. If its the second option, then we need to update the documentation/help for the same.

@navba-MSFT navba-MSFT assigned navba-MSFT and unassigned necusjz Sep 27, 2022
@navba-MSFT
Copy link
Contributor

@subhasishdc Thanks for reaching out to us and reporting this issue. We are looking into this issue and we will provide an update.

@navba-MSFT
Copy link
Contributor

@subhasishdc The portal shows how many available IP address exist in each subnet.

image

Did you check if this number in portal matched what you got with CLI command response ?

We can get the list of available Ips from Get-AzVirtualNetworkUsageList PS cmdlet as well, by subtracting the CurrentValue (no of IPs being used) from the Limit (total no of available IPs)

Example:

Get-AzVirtualNetworkUsageList -ResourceGroupName rgB -Name vnetB

Name : Subnet size and usage
Id : /subscriptions/XXXXX-XXXXX-XXXXX-XXX/resourceGroups/rgB/providers/Microsoft.Network/virtualNetworks/vnetB/subnets/default
CurrentValue : 1
Limit : 251
Unit : Count

Name : Subnet size and usage
Id : /subscriptions/XXXXX-XXXXX-XXXXX-XXX/resourceGroups/rgB/providers/Microsoft.Network/virtualNetworks/vnetB/subnets/subnet1
CurrentValue : 0
Limit : 27
Unit : Count

Could you please try and check if the above command helps and returns the required value ?

Also while debugging this further, I see that the REST API invoked by this CLI command is CheckIPAddressAvailability Rest API.

The response (output) returned here is 'Private IP address availability and list of other free addresses if the requested one is not available'. Hope this helps.

@navba-MSFT navba-MSFT added the needs-author-feedback More information is needed from author to address the issue. label Sep 27, 2022
@subhasishdc
Copy link
Contributor Author

@navba-MSFT : Checked the portal. Under available ip's, portal shows availability dependent on dynamic use. What does this mean? It is a V1 SKU application gateway and we do not have auto scaling enabled anywhere.

@ghost ghost added needs-team-attention This issue needs attention from Azure service team or SDK team and removed needs-author-feedback More information is needed from author to address the issue. labels Sep 28, 2022
@navba-MSFT
Copy link
Contributor

@subhasishdc While I get you the answer for the availability dependent on dynamic use message, May I know if you had any update on the second action plan of using Get-AzVirtualNetworkUsageList PS cmdlet mentioned in my above comment ?

@navba-MSFT navba-MSFT added needs-author-feedback More information is needed from author to address the issue. and removed needs-team-attention This issue needs attention from Azure service team or SDK team labels Sep 28, 2022
@navba-MSFT
Copy link
Contributor

navba-MSFT commented Sep 28, 2022

@subhasishdc The availability dependent on dynamic use means the subnet is being used by resource where the number of instances deployed are not fixed. Sending a sample screenshot:

image

In the screenshot, you can see its a gateway subnet. We can have gateways with multiple instances based on requirement and SKU. So it will be either a VPN gateway or Express Route gateway using this.

Another example could be, if that subnet belongs to app gateway which internally uses VMSS and they keep scaling up and down. So you need to investigate which Azure resource is using that subnet. Hope this answers.

@navba-MSFT
Copy link
Contributor

@subhasishdc I wanted to do quick follow-up to check if you had a chance to look at my above comments. Please let us know if you had any updates on this. Awaiting your reply.

@subhasishdc
Copy link
Contributor Author

@navba-MSFT : I will get back next week on this.

@ghost ghost added needs-team-attention This issue needs attention from Azure service team or SDK team and removed needs-author-feedback More information is needed from author to address the issue. labels Sep 30, 2022
@navba-MSFT
Copy link
Contributor

@subhasishdc Thanks for your reply. I shall wait for the updates from you.

@navba-MSFT navba-MSFT removed the needs-team-attention This issue needs attention from Azure service team or SDK team label Oct 3, 2022
@navba-MSFT navba-MSFT added the needs-author-feedback More information is needed from author to address the issue. label Oct 3, 2022
@subhasishdc
Copy link
Contributor Author

@navba-MSFT: Checked using the Get-AzVirtualNetworkUsageList PS cmdlet

Name : Subnet size and usage Id : /subscriptions/xyza/resourceGroups/aag-rg/providers/Microsoft.Network/virtualNetworks/aagVnet/subnets/AAG1Subnet CurrentValue : -1 Limit : -1 Unit : Count

Why it displays the negative I do not know.

However, the other subnets within the Vnet show their counts in numbers

@ghost ghost added needs-team-attention This issue needs attention from Azure service team or SDK team and removed needs-author-feedback More information is needed from author to address the issue. labels Oct 3, 2022
@navba-MSFT
Copy link
Contributor

navba-MSFT commented Oct 4, 2022

@subhasishdc Thanks for getting back. I am glad that the PS cmdlet is showing the right count in numbers.
If your AAG1Subnet subnet has availability dependent on dynamic use then you will get the CurrentValue : -1 and Limit : -1. This is expected because as I mentioned earlier, if this is subnet is used by a resource where the number of instances deployed are not fixed, then the Available IP address cannot be determine. Hope this answers.

@navba-MSFT navba-MSFT added needs-author-feedback More information is needed from author to address the issue. and removed needs-team-attention This issue needs attention from Azure service team or SDK team labels Oct 4, 2022
@subhasishdc
Copy link
Contributor Author

@navba-MSFT : That makes sense, thank you. Also, did you get a chance to figure out what's wrong with the list-available-ips output.

@ghost ghost added needs-team-attention This issue needs attention from Azure service team or SDK team and removed needs-author-feedback More information is needed from author to address the issue. labels Oct 4, 2022
@navba-MSFT
Copy link
Contributor

@subhasishdc Thanks for your reply. Regarding the list-available-ips output, it is mentioned in the documentation itself that it
List some available ips in the subnet. see here.

image

Similar question was raised here, here and here. The available workaround is to use the Get-AzVirtualNetworkUsageList PS cmdlet or use the below AzCLI command. This will show the limit ( available IP in the response for each subnet).

az rest --url "https://management.azure.com/subscriptions/XXXXXXXXXX/resourceGroups/MYRGName/providers/Microsoft.Network/virtualNetworks/MYVNETName/usages?api-version=2022-01-01"

Hope this helps.

@navba-MSFT navba-MSFT added needs-author-feedback More information is needed from author to address the issue. Mgmt This issue points to a problem in the management-plane of the library. and removed needs-team-attention This issue needs attention from Azure service team or SDK team labels Oct 7, 2022
@subhasishdc
Copy link
Contributor Author

@navba-MSFT : Thank you for the explanation. I get that part. However, the initial query remains the same.

Does list-available-ips shows some of the free and available ip addresses in the subnet. If yes, then the output is incorrect because it shows 5 ip addresses whereas only 3 should be free and available. On the other hand, if it displays some of the ip addresses in the subnet regardless of whether they are used or free, then the name is confusing and adding some explanation in the documentation would help.

@ghost ghost added needs-team-attention This issue needs attention from Azure service team or SDK team and removed needs-author-feedback More information is needed from author to address the issue. labels Oct 7, 2022
@navba-MSFT navba-MSFT added Service Attention This issue is responsible by Azure service team. and removed CXP Attention This issue is handled by CXP team. labels Oct 10, 2022
@navba-MSFT navba-MSFT removed their assignment Oct 10, 2022
@ghost
Copy link

ghost commented Oct 10, 2022

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @aznetsuppgithub.

Issue Details

I was checking the number of available ip addresses in the subnet where an application gateway is deployed using this:

schowdhu@schowdhu-mn1 ~ % az network vnet subnet list-available-ips --resource-group aag-rg --vnet-name aagVnet -n AAG1Subnet This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus [ "10.0.36.244", "10.0.36.245", "10.0.36.246", "10.0.36.247", "10.0.36.248" ]

Following shows my subnet size and the app gw instances deployed.

[schowdhu@schowdhu-ld3 ~]$ az network vnet subnet show -g aag-rg -n AAG1Subnet --vnet-name aagVnet | jq '.addressPrefix' "10.0.36.240/28"

[schowdhu@schowdhu-ld3 ~]$ az network application-gateway list -g aag-rg | jq '.[] | .name,.sku,.operationalState' "aag01" { "capacity": 8, "name": "Standard_Medium", "tier": "Standard" } "Running"

Based on the app gw documentation (https://docs.microsoft.com/en-us/azure/application-gateway/configuration-infrastructure#size-of-the-subnet), app gw uses one private IP address per instance, plus another private IP address if a private front-end IP is configured. Azure also reserves five IP addresses in each subnet for internal use: the first four and the last IP addresses. Taking the above example for reference, total available ip addresses in the subnet 10.0.36.240/28 is 16. Azure uses 5 ip addresses and app gw has 8 instances. There should be only 3 ip addresses remaining. However, the az network vnet subnet list-available-ips command shown above shows 5 ip addresses available.

https://learn.microsoft.com/en-us/cli/azure/network/vnet/subnet?view=azure-cli-latest#az-network-vnet-subnet-list-available-ips -- This is the example in the documentation. It mentions "List some available ips in the subnet.". Does it mean it shows free ip addresses which are not used yet in the subnet or just it just display a few ip addresses belonging to the subnet irrespective of weather they are being used or not.

Am I missing something here or is there an issue with what the command is showing.

Author: subhasishdc
Assignees: navba-MSFT
Labels:

Network, Service Attention, question, customer-reported, Mgmt, needs-team-attention, Auto-Assign, Azure CLI Team

Milestone: Backlog

@navba-MSFT
Copy link
Contributor

@subhasishdc Thanks for your reply. I am adding the Service team to look into this ask and assist you further.

@aznetsuppgithub Could you please look into this ask and provide an update ? Thanks in advance.

@maciejduk
Copy link

I am not sure if this is still an ongoing issue, but since it's open and my results are similar to the OP, I will post here:

I have an empty /24 subnet. The list-available-ips command shows only 5 addresses available:
image

Portal shows below:
image

Am I understanding the purpose of this command wrong? I would've imagined list of free IPs would be 251 addresses long (as per portal, and the fact it's /24, minus 5 addresses for Azure services = 251).

@atharva-sarage
Copy link

atharva-sarage commented Jul 27, 2023

I looked into the code as of 7/27/2023 the value 5 is hardcoded and it doesn't fetch the entire list.
Also this API is intelligent where it checks if the requested IP belongs to any subnet and throws this error if not.

{
  "error": {
    "code": "PrivateIPAddressNotInAnySubnet",
    "message": "Private static IP address 0.0.0.0 does not belong to the range of any subnet in the virtual network /subscriptions/<subId>/resourceGroups/<rg>/providers/Microsoft.Network/virtualNetworks/<vnetName>.",
    "details": []
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue points to a problem in the management-plane of the library. needs-team-attention This issue needs attention from Azure service team or SDK team Network az network vnet/lb/nic/dns/etc... question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

7 participants