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

[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

Open
3 tasks
abhishekpankaj54 opened this issue Oct 18, 2024 · 10 comments
Assignees
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

Comments

@abhishekpankaj54
Copy link

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(
"",
"",
"",
""
);

    // Get the network you want to list the subnets for
    Network network = networkManager.networks().getByResourceGroup("<your-resource-group>", "<your-network-name>");

    // Iterate over the subnets and print their parameters
    PagedIterable<Subnet> subnets = network.subnets().list();
    for (Subnet subnet : subnets) {
        System.out.println("Subnet ID: " + subnet.id());
        System.out.println("Subnet Name: " + subnet.name());
        if (subnet.inner().addressPrefix()!=null){

System.out.println("Subnet Address Prefix: " + subnet.addressPrefix());
}
else{
System.out.println("Subnet Address Prefixes: " + subnet.inner().addressPrefixes().get(0));
}

           System.out.println("Subnet listAvailablePrivateIPAddresses: " + subnet.listAvailablePrivateIPAddresses());   ///  
        
       
        System.out.println();
    }
}

}
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):

  • OS: [e.g. iOS]
  • IDE: [e.g. IntelliJ] Intellij
  • Library/Libraries: [e.g. com.azure:azure-core:1.16.0 (groupId:artifactId:version)]
  • Java version: [e.g. 8] :java 17
  • App Server/Environment: [e.g. Tomcat, WildFly, Azure Function, Apache Spark, Databricks, IDE plugin or anything special]
  • Frameworks: [e.g. Spring Boot, Micronaut, Quarkus, etc]

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: NO

  • verbose dependency tree (mvn dependency:tree -Dverbose)
  • exception message, full stack trace, and any available logs

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

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
@github-actions github-actions bot added 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 labels Oct 18, 2024
Copy link

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@abhishekpankaj54
Copy link
Author

@weidongxu-microsoft , Could you please have a look at it urgently? If you want more info please let me know.

@abhishekpankaj54
Copy link
Author

@weidongxu-microsoft Did you check this?

@weidongxu-microsoft
Copy link
Member

@XiaofeiCao Could you take a look? If there is bug we'd like to fix it before Oct. release.

@abhishekpankaj54
Copy link
Author

@XiaofeiCao , Please update us as soon as possible, as our application is being impacted by this.

@abhishekpankaj54
Copy link
Author

@XiaofeiCao , Did you get a chance to look into this?

@XiaofeiCao
Copy link
Contributor

@XiaofeiCao , Did you get a chance to look into this?

Yeah, I'm looking into this. This is an SDK bug and we've found the root cause. I'm working on a fix and should be able to release a new version this week.

@abhishekpankaj54
Copy link
Author

@XiaofeiCao , Thanks for the Update, please update me once it is released.

@abhishekpankaj54
Copy link
Author

abhishekpankaj54 commented Oct 22, 2024

@XiaofeiCao , Will you be releasing a new version of the Azure Java SDK to address this fix? The latest version is 2.43.0 , so I assume a new version will be released by the end of October?

https://mvnrepository.com/artifact/com.azure.resourcemanager/azure-resourcemanager

@XiaofeiCao
Copy link
Contributor

@abhishekpankaj54 yes, target release date for 2.44.0 is 10/25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
Status: Todo
Development

No branches or pull requests

3 participants