gpt4 book ai didi

java - Azure Java : cannot add plan information while creating VM

转载 作者:行者123 更新时间:2023-12-02 12:20:13 24 4
gpt4 key购买 nike

版本:1.1.0

我正在使用市场镜像创建虚拟机。我的代码看起来像这样

VirtualMachine linuxVM = azure.virtualMachines().define(name)
.withRegion(Region.US_WEST)
.withExistingResourceGroup(myRg)
.withExistingPrimaryNetwork(network)
.withSubnet("subnet1")
.withPrimaryPrivateIPAddressDynamic()
.withNewPrimaryPublicIPAddress("ip-" + name)
.withLatestLinuxImage("publisher", "offer", "sku")
.withRootUsername("root")
.withRootPassword("some password")
.withSize(VirtualMachineSizeTypes.BASIC_A0)
.create();

我收到如下错误。

Async operation failed with provisioning state: Failed: Creating a virtual machine from Marketplace image requires Plan information in the request. OS disk name is '<name>'

如何添加计划信息?

最佳答案

在花了一些时间研究源代码之后,看起来计划信息可以添加到 VM 创建中。以下代码适用于 1.1.0。

PurchasePlan plan = new PurchasePlan();
plan.withName("name");
plan.withPublisher("publisher");
plan.withProduct("prodcut");

VirtualMachine linuxVM = azure.virtualMachines().define(name)
.withRegion(Region.US_WEST)
.withExistingResourceGroup(myRg)
.withExistingPrimaryNetwork(network)
.withSubnet("subnet1")
.withPrimaryPrivateIPAddressDynamic()
.withNewPrimaryPublicIPAddress("ip-" + name)
.withLatestLinuxImage("publisher", "offer", "sku")
.withRootUsername("root")
.withRootPassword("some password")
.withSize(VirtualMachineSizeTypes.BASIC_A0)
.withPlan(plan)
.create();

关于java - Azure Java : cannot add plan information while creating VM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45846954/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com