如本官方文档所述:
在非托管磁盘中,您管理用于存储与您的 VM 磁盘对应的虚拟硬盘 (VHD) 文件的存储帐户。VHD 文件作为页 blob 存储在 Azure 存储帐户中。
您可以按照教程将 VHD 文件上传到您的存储帐户,然后使用 指定存储帐户。请参阅此处.storeAt(storageAccount.name(), "diskvhds", "datadisk1vhd.vhd")
的源代码。
VirtualMachine virtualMachine = computeManager.virtualMachines()
.define(VMNAME)
.withRegion(REGION)
.withExistingResourceGroup(RG_NAME)
.withNewPrimaryNetwork("10.0.0.0/28")
.withPrimaryPrivateIPAddressDynamic()
.withoutPrimaryPublicIPAddress()
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
.withRootUsername("Foo12")
.withRootPassword("abc!@#F0orL")
.withUnmanagedDisks()
.defineUnmanagedDataDisk("disk1")
.withNewVhd(100)
.withLun(2)
.storeAt(storageAccount.name(), "diskvhds", "datadisk1vhd.vhd")
.attach()
.defineUnmanagedDataDisk("disk2")
.withNewVhd(100)
.withLun(3)
.storeAt(storageAccount.name(), "diskvhds", "datadisk2vhd.vhd")
.attach()
.withSize(VirtualMachineSizeTypes.STANDARD_DS2_V2)
.withOSDiskCaching(CachingTypes.READ_WRITE)
.create();
注意
.storeAt(storageAccount.name(), "diskvhds", "datadisk1vhd.vhd")
方法.storeAt(<your account name>, <container name>, <blob name>)