【问题标题】:Azure Java: cannot add plan information while creating VMAzure Java:创建 VM 时无法添加计划信息
【发布时间】:2018-02-01 11:17:53
【问题描述】:

版本:1.1.0

我正在使用市场映像创建 VM。我的代码看起来像这样

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>'

如何添加计划信息?

【问题讨论】:

  • 我尝试将“publisher”、“offer”、“sku”替换为“OpenLogic”、“CentOS”、“7.3”,以正常运行您提供的代码,不包括 Plan。请您提供您的“publisher”、“offer”、“sku”具体参数和其他重要参数,以便我帮助您找到问题的解决方案。

标签: java azure azure-java-sdk azure-management


【解决方案1】:

在使用源代码一段时间后,似乎可以将计划信息添加到 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();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-20
    • 1970-01-01
    • 2018-10-21
    • 1970-01-01
    • 2016-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多