Azure / azure-libraries-for-java

Azure Management Libraries for Java
https://docs.microsoft.com/en-us/java/azure/
MIT License
94 stars 98 forks source link

[BUG] NPE from .disks().getById(diskId) #1255

Open metaldectr opened 4 years ago

metaldectr commented 4 years ago

Exception or Stack Trace Caused by java.lang.IllegalArgumentException: Parameter resourceGroupName is required and cannot be null. /opt/lib/azure-mgmt-compute-1.22.0.jar!/com/microsoft/azure/management/compute/implementation/DisksInner.class:529 in getByResourceGroupWithServiceResponseAsync /opt//lib/azure-mgmt-compute-1.22.0.jar!/com/microsoft/azure/management/compute/implementation/DisksInner.class:508 in getByResourceGroupAsync /opt/lib/azure-mgmt-resources-1.22.0.jar!/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/TopLevelModifiableResourcesImpl.class:64 in getInnerAsync /opt/lib/azure-mgmt-resources-1.22.0.jar!/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.class:115 in getByResourceGroupAsync /opt/lib/azure-mgmt-resources-1.22.0.jar!/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.class:80 in getByIdAsync /opt/lib/azure-mgmt-resources-1.22.0.jar!/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.class:69 in getById /opt/lib/azure-mgmt-resources-1.22.0.jar!/com/microsoft/azure/management/resources/fluentcore/arm/collection/implementation/GroupableResourcesImpl.class:34

Setup (please complete the following information):

weidongxu-microsoft commented 4 years ago

@metaldectr

Could you share your disk ID? The exception seems be caused by invalid resource ID (hence the resource group cannot be extraced).

metaldectr commented 4 years ago

I get diskId from vm.dataDisks()

VirtualMachine /**

and get Id from this object.

weidongxu-microsoft commented 4 years ago

@metaldectr Would you help paste the id here (with redact if you prefer)?

I am fine with my test (with 1.36.0)

            var vm = azure.virtualMachines().getById(VM_ID);
            var id = vm.dataDisks().entrySet().iterator().next().getValue().id();

            var disk = azure.disks().getById(id);

The format of the ID would be

/subscriptions/{subscription}/resourceGroups/{resourcegroup}/providers/Microsoft.Compute/disks/{disk}