0

I'm using azure-libraries-for-java (https://github.com/Azure/azure-libraries-for-java/) to handle some azure management stuff, and one of the features I'm not able to figure out is hot to attach a managed disk to a vmss instance.

This action can be done very simply with az cli: az vmss disk attach --disk {diskid} --instance-id 0 --resource-group MyResourceGroup --lun 0

It can also be done in a slightly more complicated way using the rest API as described here: https://github.com/Azure/vm-scale-sets/tree/master/preview/disk

But I can't figure out how to replicate either of these methods using the java SDK. Hopefully someone is more familiar with it to help understand if or how it can be done!

Thanks.

Cesar
  • 2,027
  • 2
  • 18
  • 29
  • Do you try the interface [VirtualMachineScaleSet.UpdateStages.WithManagedDataDisk](https://learn.microsoft.com/en-us/java/api/com.microsoft.azure.management.compute.virtualmachinescaleset.updatestages.withmanageddatadisk?view=azure-java-stable)? I think it will help, but it seems just create the new data disk. If it helps, please let me know. – Charles Xu Jun 13 '19 at 08:12
  • Yes I've seen this, but as you say it seems it can only be used to create new/empty data disks, and it will create them for each VM instance in the scale set, not just a specific one. – Cesar Jun 13 '19 at 08:19
  • It seems there is no other interface to do that. Maybe you can use the rest API in the java code. – Charles Xu Jun 13 '19 at 08:29

1 Answers1

0

I managed to resolve this issue by using the inner() functions in the java sdk. As I now understand it, these functions/classes are autogenerated from the rest API so any functionality in the rest API will have at least corresponding functionality there.

It's a bit uglier to work with and apparently at risk of losing backwards compatibility with new versions of the SDK, but I'm very relieved I won't have to call the rest api manually :p

Cesar
  • 2,027
  • 2
  • 18
  • 29