从自定义映像创建Azure VM [英] Creating Azure VM from custom image

查看:107
本文介绍了从自定义映像创建Azure VM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储在Azure中的映像,我想从中启动多个VM.我已经创建了一个模板,该模板将为我创建必要的资源,并且除了创建VM外,所有资源均成功.

I have an image stored in Azure that I want to spin up multiple VMs from. I've created a template that will create the necessary resources for me and all of them succeed except the VM creation.

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

Using CreateOption.FromImage runs the deployment for around 40 minutes until I get the error:

在分配的时间内针对VM'vmName'的OS配置未完成.但是,检测到VM guest虚拟机代理正在运行.这表明客户机操作系统尚未正确准备好用作VM映像(使用CreateOption = FromImage).要解决此问题,请按原样使用VHD(与CreateOption = Attach配合使用)或适当地准备将其用作图像

'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会立即给我以下错误:

Changing CreateOption.FromImage to CreateOption.Attach gives me the following error immediately:

如果虚拟机是从平台或用户映像创建的,则无法附加现有的OS磁盘.

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

我要通过模板实现的目标:

What I'm trying to achieve through the template:

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

以下是我用来部署的模板的VM部分:

Below is the VM portion of the template I'm using to deploy:

{
  "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'))]"
        }
      ]
    }
  }
}

推荐答案

在分配的时间内针对VM'vmName'的OS配置未完成.但是,检测到VM guest虚拟机代理正在运行.这表明客户机操作系统尚未正确准备好用作VM映像(使用CreateOption = FromImage).要解决此问题,请按原样使用VHD(与CreateOption = Attach配合使用)或适当地准备将其用作图像

'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

如果您使用未经过系统准备的映像来创建VM,则可能会导致错误,因此请确保您的映像已通过系统准备.

If you are using the image that is not sysprepped to create VM, it could cause the error, so please make sure your image is sysprepped.

如果虚拟机是从平台或用户映像创建的,则无法附加现有的OS磁盘.

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

当您指定要附加的CreateOption(它将从专用磁盘创建虚拟机)时,请不要指定SourceImageUri参数.有关更多信息,请从本文档.

When you specify CreateOption to Attach ( it will create a virtual machine from a specialized disk), do not specify the SourceImageUri parameter. For more information, please check "-CreateOption" from this documentation.

这篇关于从自定义映像创建Azure VM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆