0

I am using Azure Java SDK and am trying to get a list of all the orphaned disks in the subscription. Is there a way in the current Azure Java SDK to get this list ?

user1142317
  • 533
  • 1
  • 8
  • 20

2 Answers2

1

i dont think there a way in any SDK (as there is no way to find that using the REST API), so no. There is no such way.

But if you are talking about managed disks take a look at this API request, you can infer from the date:
https://learn.microsoft.com/en-us/rest/api/manageddisks/disks/disks-list-by-subscription

"diskState": "Unattached" 
4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • For the managed disk the information is available using the latest Java Azure SDK. But for unmanaged disks this info seems to be missing. – user1142317 May 25 '17 at 21:13
  • unmanaged disk you would be looking for .VHD extensions that are not "leased". This should be a property on the blob itself. – CtrlDot May 26 '17 at 01:35
1

I haven't experimented with the Java SDK too much, but essentially VHDs that are attached to VMs have an infinate lease applied to them. In order to look for orphaned disks, you could examine the blob properties for any blobs that end in vhd.

I believe getLeaseDuration() or getLeaseState() should do the trick.

CtrlDot
  • 2,463
  • 14
  • 11