[BUG][JAVA SDK]We have observed that the listAvailablePrivateIPAddresses method, which we use to list the available IPs of a subnet, does not work when the subnet has only AddressPrefixes instead of a AddressPrefix. #42457
Labels
azure-spring
All azure-spring related issues
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
Mgmt
This issue is related to a management-plane library.
needs-team-attention
Workflow: This issue needs attention from Azure service team or SDK team
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Describe the bug
[JAVA SDK]We have observed that the listAvailablePrivateIPAddresses method, which we use to list the available IPs of a subnet, does not work when the subnet has only AddressPrefixes instead of a AddressPrefix.
When you list the Vnet details via Azure SDK you will have all the subnet info of that Vnet and its value/parameters. We found when the subnet only has the AddressPrefix as a parameter it can get the AvailablePrivateIPAddresses using listAvailablePrivateIPAddresses method but when subnet only have the AddressPrefixes instead of addressPrefix this method( listAvailablePrivateIPAddresses) does not list the Available IP even we have the Free available IPs(Verified by azure cloud shell command).
Example of Vnet'subnet :
"subnets": [
{
"addressPrefixes": [
"10.0.0.0/29"
],
"delegations": [],
"etag": "W/"043b41c2-cdf2-45f6-a425-dfe908a9dd4e"",
"id":
Here for this Subnet we can not get the free IPs as it has addressPrefixes as a parameter and addressPrefix parameter is missing.
Exception or Stack Trace
DEBUG [2024-10-17 08:47:47,759] [main] [AzureClientFactory:getCloudTargetNetworksFromProvider:205]: Subnet name prismacloud-scan-1729154298905891729
DEBUG [2024-10-17 08:47:47,759] [main] [AzureClientFactory:getCloudTargetNetworksFromProvider:207]: Subnet addressPrefix 10.0.0.0/24
DEBUG [2024-10-17 08:47:47,885] [main] [AzureClientFactory:getCloudTargetNetworksFromProvider:210]: Subnet listAvailablePrivateIPAddresses [10.0.0.4, 10.0.0.5, 10.0.0.6, 10.0.0.7, 10.0.0.8]
DEBUG [2024-10-17 08:47:47,885] [main] [AzureClientFactory:getCloudTargetNetworksFromProvider:205]: Subnet name default
DEBUG [2024-10-17 08:47:47,885] [main] [AzureClientFactory:getCloudTargetNetworksFromProvider:209]: Subnet addressPrefixes 10.0.0.0/24
DEBUG [2024-10-17 08:47:47,886] [main] [AzureClientFactory:getCloudTargetNetworksFromProvider:210]: Subnet listAvailablePrivateIPAddresses []
DEBUG [2024-10-17 08:47:47,886] [main] [AzureClientFactory:getCloudTargetNetworksFromProvider:205]: Subnet name default
DEBUG [2024-10-17 08:47:47,886] [main] [AzureClientFactory:getCloudTargetNetworksFromProvider:207]: Subnet addressPrefix 10.1.0.0/24
DEBUG [2024-10-17 08:47:48,020] [main] [AzureClientFactory:getCloudTargetNetworksFromProvider:210]: Subnet listAvailablePrivateIPAddresses [10.1.0.4, 10.1.0.5, 10.1.0.6, 10.1.0.7, 10.1.0.8]
DEBUG [2024-10-17 08:47:48,020] [main] [AzureClientFactory:getCloudTargetNetworksFromProvider:205]: Subnet name defaultSubnet
DEBUG [2024-10-17 08:47:48,020] [main] [AzureClientFactory:getCloudTargetNetworksFromProvider:207]: Subnet addressPrefix 10.15.0.0/24
DEBUG [2024-10-17 08:47:48,523] [main] [AzureClientFactory:getCloudTargetNetworksFromProvider:210]: Subnet listAvailablePrivateIPAddresses [10.15.0.4, 10.15.0.5, 10.15.0.6, 10.15.0.7, 10.15.0.8]
To Reproduce
Just Create the Vnet and its subnet using Azure portal and list the Vnet details(Using CLI/or API calls) so you will have the addressPrefixes as a parameter of the subnet and try to build a simple java program as mentioned below.
Code Snippet
Sample code :
public class AzureSubnetList {
public static void main(String[] args) {
// Create a NetworkManager instance with your Azure credentials
NetworkManager networkManager = NetworkManager.authenticate(
"",
"",
"",
""
);
System.out.println("Subnet Address Prefix: " + subnet.addressPrefix());
}
else{
System.out.println("Subnet Address Prefixes: " + subnet.inner().addressPrefixes().get(0));
}
}
Note that you'll need to replace the placeholders (, , , , , ) with your actual Azure subscription ID, client ID, client secret, tenant ID, resource group, and network name.
Also, make sure you have the Azure Java SDK added to your project's dependencies. You can find the Maven coordinates for the SDK here: https://mvnrepository.com/artifact/com.azure.resourcemanager/azure-resourcemanager-network
Expected behavior
We should have the list of all private Available Ips.
Screenshots
If applicable, add screenshots to help explain your problem.
Setup (please complete the following information):
If you suspect a dependency version mismatch (e.g. you see
NoClassDefFoundError
,NoSuchMethodError
or similar), please check out Troubleshoot dependency version conflict article first. If it doesn't provide solution for the problem, please provide: NOmvn dependency:tree -Dverbose
)Additional context
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
The text was updated successfully, but these errors were encountered: