[英]Raise Azure VM from marketplace image via C#
無法以編程方式從市場映像中引發 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 中,我為給定的圖像啟用了“想要以編程方式部署?開始”(如此處所述)。
關於選擇圖像的方法有幾個選項,不確定應該使用哪種方法以及使用哪些參數。 嘗試了幾種組合,但都返回了 misc 錯誤消息。
沒有找到更詳細的代碼示例(它沒有解釋如何使用來自市場的圖像)。
編輯:
上面的代碼返回這個異常:
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"
)))
缺少的參數是圖像的版本。 提升圖像的代碼如下所示:
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();
也可以通過 CLI 獲取所有圖像的詳細信息:
Get-AzVMImageOffer -Location "West Europe" -PublisherName nvidia
可以在這里找到更完整的指南
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.