Closed yihan-go closed 1 year ago
You had to do it without convenient code.
azure
.virtualMachines()
.manager()
.inner()
.virtualMachines()
.createOrUpdate(
"myResourceGroup",
"myVM",
(VirtualMachineInner) new VirtualMachineInner()
.withHardwareProfile(new HardwareProfile().withVmSize(VirtualMachineSizeTypes.STANDARD_D1_V2))
.withStorageProfile(
new StorageProfile()
.withImageReference(
new ImageReference()
.withPublisher("{image_publisher}")
.withOffer("{image_offer}")
.withSku("{image_sku}")
.withVersion("latest"))
.withOsDisk(
new OSDisk()
.withName("myVMosdisk")
.withCaching(CachingTypes.READ_WRITE)
.withCreateOption(DiskCreateOptionTypes.FROM_IMAGE)
.withManagedDisk(
new ManagedDiskParameters()
.withStorageAccountType(StorageAccountTypes.STANDARD_LRS)
.withDiskEncryptionSet((DiskEncryptionSetParameters) new DiskEncryptionSetParameters()
.withId("id")))))
.withOsProfile(
new OSProfile()
.withComputerName("myVM")
.withAdminUsername("{your-username}")
.withLinuxConfiguration(
new LinuxConfiguration()
.withDisablePasswordAuthentication(true)
.withSsh(
new SshConfiguration()
.withPublicKeys(
Arrays
.asList(
new SshPublicKeyInner()
.withPath("/home/{your-username}/.ssh/authorized_keys")
.withKeyData(
"ssh-rsa"
+ " AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1"))))))
.withNetworkProfile(
new NetworkProfile()
.withNetworkInterfaces(
Arrays
.asList(
((NetworkInterfaceReference) new NetworkInterfaceReference()
.withId(
"/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"))
.withPrimary(true))))
.withLocation("westus")
);
Thanks for the fast reply and useful code example!
Query/Question We could use the API template (2019-07-01) to config a VM with dataDisk with DiskEncryptionSet(DES) id like this But we are struggled to do it with SDK (1.41.0), we only found things like this but could not find a place to config the DES id. Is this supported with the given version? If so, is there any code example that we could refer to?
Setup (please complete the following information if applicable):
SDK Version:1.41.0
Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report