【问题标题】:Raise Azure VM from marketplace image via C#通过 C# 从市场映像中提升 Azure VM
【发布时间】:2020-12-13 18:29:26
【问题描述】:

未能以编程方式从 marketplace image 引发 azure VM。

代码:

var linuxVM = await _azure.VirtualMachines.Define(linuxVmName)
          .WithRegion(Region)
          .WithExistingResourceGroup(rgName)
          .WithNewPrimaryNetwork("10.0.0.0/28")
          .WithPrimaryPrivateIPAddressDynamic()
          .WithoutPrimaryPublicIPAddress()
          .WithSpecificLinuxImageVersion(new ImageReference())
          .WithRootUsername(userName)
          .WithRootPassword(password)
          .WithSize(VirtualMachineSizeTypes.StandardNC6sV3)
          .WithPlan(new PurchasePlan("nvidia", "ngc-base-version-20-10-1", "ngc_azure_17_11"))
          .CreateAsync();

在 Azure 中,我为给定映像启用了“想要以编程方式部署?开始吧”(如 here 所述)。

关于选择图像的方法有几个选项,不确定应该使用哪种方法以及使用哪些参数。尝试了几种组合,但都返回了 misc 错误消息。

没有找到更详细的代码示例this(它没有解释如何使用来自市场的图像)。


编辑:

上面的代码返回这个异常:

Microsoft.Rest.Azure.CloudException: 'This resource was created without a plan. A new plan cannot be associated with an update.'

另一个使用更多填充参数的尝试导致相同的异常:

.WithSpecificLinuxImageVersion(new ImageReference(new ImageReferenceInner(
                          publisher: "nvidia",
                          offer: "ngc_azure_17_11",
                          sku: "ngc-base-version-20-10-1"
                          )))

【问题讨论】:

标签: c# azure azure-marketplace


【解决方案1】:

缺少的参数是图像的版本。提升图像的代码如下所示:

    var vm = await _azure.VirtualMachines.Define(linuxVmName)
          .WithRegion(_region)
          .WithExistingResourceGroup(_rgName)
          .WithNewPrimaryNetwork("10.0.0.0/28")
          .WithPrimaryPrivateIPAddressDynamic()
          .WithoutPrimaryPublicIPAddress()
          .WithSpecificLinuxImageVersion(new ImageReference(new ImageReferenceInner(
              publisher: "nvidia",
              offer: "ngc_azure_17_11",
              sku: "ngc-base-version-20-10-1",
              version: "20.10.1"
              )))
          .WithRootUsername(userName)
          .WithRootPassword(password)
          .WithSize(VirtualMachineSizeTypes.StandardNC6sV3)
          .WithPlan(new PurchasePlan("nvidia", "ngc-base-version-20-10-1", "ngc_azure_17_11"))
          .CreateAsync();

版本可以在 UI 中找到:

还可以通过 CLI 获取所有图像的详细信息:

Get-AzVMImageOffer -Location "West Europe" -PublisherName nvidia

可以找到更完整的指南here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-01
    • 1970-01-01
    • 2017-05-07
    • 2018-04-23
    • 1970-01-01
    相关资源
    最近更新 更多