gpt4 book ai didi

.net - 从自定义镜像创建 Azure VM

转载 作者:行者123 更新时间:2023-12-02 23:48:50 29 4
gpt4 key购买 nike

我有一个存储在 Azure 中的镜像,我想从中启动多个虚拟机。我创建了一个模板,它将为我创建必要的资源,除了创建虚拟机之外,所有这些资源都会成功。

使用 CreateOption.FromImage 运行部署大约 40 分钟,直到出现错误:

'OS Provisioning for VM 'vmName' did not finish in the allotted time. However, the VM guest agent was detected running. This suggests the guest OS has not been properly prepared to be used as a VM image (with CreateOption=FromImage). To resolve this issue, either use the VHD as is with CreateOption=Attach or prepare it properly for use as an image

CreateOption.FromImage 更改为 CreateOption.Attach 会立即出现以下错误:

Cannot attach an existing OS disk if the VM is created from a platform or user image.

我想通过模板实现什么:

  1. 指向主图像
  2. 提供母版副本所需的目的地
  3. 将主镜像复制到目标位置
  4. 创建虚拟机
  5. 将副本附加到虚拟机

下面是我用来部署的模板的虚拟机部分:

{
"apiVersion": "2015-06-15",
"type": "Microsoft.Compute/virtualMachines",
"name": "[parameters('vmName')]",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "VirtualMachine"
},
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', parameters('nicName'))]"
],
"properties": {
"osProfile": {
"computerName": "[parameters('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"hardwareProfile": {
"vmSize": "[variables('vmSize')]"
},
"storageProfile": {
"osDisk": {
"name": "[parameters('OSDiskName')]",
"osType": "windows",
"caching": "ReadWrite",
"createOption": "FromImage",
"image": {
"uri": "[concat('https://', parameters('storageAccountName'), '.blob.core.windows.net/', parameters('sourceStorageContainerName'), '/', parameters('sourceVHDName'), '.vhd')]"
},
"vhd": {
"uri": "[concat('https://', parameters('storageAccountName'), '.blob.core.windows.net/', parameters('vhdStorageContainerName'), '/', parameters('OSDiskName'), '.vhd')]"
}
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('nicName'))]"
}
]
}
}
}

最佳答案

'OS Provisioning for VM 'vmName' did not finish in the allotted time. However, the VM guest agent was detected running. This suggests the guest OS has not been properly prepared to be used as a VM image (with CreateOption=FromImage). To resolve this issue, either use the VHD as is with CreateOption=Attach or prepare it properly for use as an image

如果您使用未经过系统准备的镜像来创建虚拟机,可能会导致错误,因此请确保您的镜像经过系统准备。

enter image description here

Cannot attach an existing OS disk if the VM is created from a platform or user image.

当您指定 CreateOption to Attach 时(它将从专用磁盘创建虚拟机),请勿指定 SourceImageUri 参数。欲了解更多信息,请查看this documentation中的“-CreateOption” .

关于.net - 从自定义镜像创建 Azure VM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41272627/

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