I don't find any option to set the VM generation, by default its 1 but i need to change it to 2.
Azure portal create disk
Disk managedDisk = azure.disks().define("myosdisk") .withRegion(Region.US_EAST2) .withExistingResourceGroup("test") .withWindowsFromVhd ("https://abcd.blob.core.windows.net/vm/‘laptop_vm’.vhd") .withSizeInGB(500).withSku(DiskSkuTypes.PREMIUM_LRS).create();
You can use
hyperVGeneration
set function. The hypervisor generation of the Virtual Machine. Applicable to OS disks only. Possible values include: 'V1', 'V2'Possible call
withHyperVGeneration('V2');
Checkout azure-sdk-java implementation for details.
You need to import
mgmt.compute
libraries. It can be found in below maven artifact.You can call disk creation as below
More information can be found in Github Azure/azure-sdk-for-java repository.