Reputation: 1
Azure portal allows us to select the os disk type (HDD/SSD) while creating virtual machine. But when I try to deploy the virtual machine using java SDK there is no support available from the API to pass the disk type.
var linuxVM1 = azure.VirtualMachines
.Define(linuxVM1Name)
.WithRegion(Region.USEast)
.WithNewResourceGroup(rgName)
.WithNewPrimaryNetwork("10.0.0.0/28")
.WithPrimaryPrivateIpAddressDynamic()
.WithNewPrimaryPublicIpAddress(linuxVM1Pip)
.WithPopularLinuxImage(KnownLinuxVirtualMachineImage.UbuntuServer16_04_Lts)
.WithRootUsername(“tirekicker”)
.WithSsh(sshkey)
.WithNewDataDisk(100)
.WithSize(VirtualMachineSizeTypes.StandardD3V2)
.Create();
Can anyone please provide me the pointer on how to set the disk type during virtual machine provisioning.
Thanks in advance
Upvotes: 0
Views: 197
Reputation: 24569
can anyone please provide me the pointer on how to set the disk type during virtual machine provisioning.
If you want to select os disk type (HDD/SSD) please append .withOSDiskStorageAccountType(StorageAccountTypes.PREMIUM_LRS)
. PREMIUM_LRS means that uses the SSD disk. If you want to choose HDD disk you could use StorageAccountTypes.STANDARD_LRS
. The following is the demo code.
var linuxVM1 = azure.VirtualMachines
.Define(linuxVM1Name)
.withRegion(Region.USEast)
.withNewResourceGroup(rgName)
.withNewPrimaryNetwork("10.0.0.0/28")
.withPrimaryPrivateIpAddressDynamic()
.withNewPrimaryPublicIpAddress(linuxVM1Pip)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UbuntuServer16_04_Lts)
.withRootUsername(“tirekicker”)
.withSsh(sshkey)
.withOSDiskStorageAccountType(StorageAccountTypes.PREMIUM_LRS) //StorageAccountTypes.STANDARD_LRS
.withNewDataDisk(100)
.withSize(VirtualMachineSizeTypes.StandardD3V2)
.create();
Upvotes: 1