【问题标题】:New-AzureRmVM : Long running operation failed with status 'Failed' ErrorCode: VMAgentStatusCommunicationErrorNew-AzureRmVM:长时间运行操作失败,状态为“失败”错误代码:VMAgentStatusCommunicationError
【发布时间】:2017-04-26 23:53:09
【问题描述】:

所以我正在尝试通过 Powershell 从 VHD(从在 Hyper-V 中运行的服务器)创建 Azure VM。创建过程失败并出现以下错误:

New-AzureRmVM : Long running operation failed with status 'Failed'.
ErrorCode: VMAgentStatusCommunicationError
ErrorMessage: VM 'Server' has not reported status for VM agent or extensions. Please verify the VM has a running VM agent, and can establish outbound connections to Azure storage.
StartTime: 4/24/2017 12:26:57 PM
EndTime: 4/24/2017 12:52:39 PM
OperationID: 71739dce-4052-4114-82a4-dda1c3476711
Status: Failed
At line:10 char:7
+ $vm = New-AzureRmVM -VM $VMconfig -Location $location -ResourceGroupN ...
+       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzureRmVM], ComputeCloudException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand

我已将 Azure VM 代理安装到 Hyper-V 中的虚拟机上。我阅读了有关该错误的following post,并且 cmets 中的某个人说您需要允许 https 访问存储帐户。我在设置中到处找,我不知道该怎么做。我错过了什么吗?会不会有其他原因导致失败?

此外,创建的 azure 虚拟机看起来运行良好,但我无法对其进行 RDP,即使我在上传 vhd 之前启用了远程桌面连接。

任何帮助将不胜感激。

提前致谢!

编辑:这是我的源代码:

Login-AzureRmAccount
$vhdname = Read-Host "Please enter the new name of the VHD in Azure"
$vhdurl = "https://***********.blob.core.windows.net/******/$vhdname"
$resourcegroup = Read-Host "Please enter the Azure resource group for the VM"
$servername = Read-Host "Please enter name of Azure server to be created"
$virtualnetwork = Read-Host "Please enter the name of the Azure virtual network to be used"
$VMsize = Read-Host "Please enter the vm size in Azure (i.e. Basic_A0)"
$location = Read-Host "Please enter the region of the server (i.e. westus)"

$virtualnetworkinfo = Get-AzureRmVirtualNetwork -ResourceGroupName $resourcegroup -Name $virtualnetwork

$publicIp = New-AzureRmPublicIpAddress -Name $servername -ResourceGroupName $resourcegroup -Location $location -AllocationMethod Dynamic
$networkInterface = New-AzureRmNetworkInterface -ResourceGroupName $resourcegroup -Name "$servername`_VirtualNetworkInterface" -Location $location -SubnetId $virtualnetworkinfo.Subnets[0].Id -PublicIpAddressId $publicIp.Id

$VMconfig = New-AzureRmVMConfig -VMName $servername -VMSize $VMsize
$VMconfig = Set-AzureRmVMOSDisk -VM $VMconfig -Name $servername -VhdUri $vhdurl -CreateOption Attach -Windows
$VMconfig = Add-AzureRmVMNetworkInterface -VM $VMconfig -Id $networkInterface.Id

$vm = New-AzureRmVM -VM $VMconfig -Location $location -ResourceGroupName $resourcegroup

【问题讨论】:

  • 能否请您添加用于创建 VM 的代码片段。此外,门户中“扩展”选项卡的屏幕截图以及此处列出的任何错误(如果与上述不同)。
  • 你打开Azure NSG上的3389端口了吗?
  • @Jesse 你有 NSG 或防火墙块 443(出站)吗?
  • @CtrlDot 我将用我的代码编辑原始位
  • @Walter-MSFT 是的,我确实打开了 3389,但我没有阻止 443 出站。我应该这样做吗?

标签: powershell azure


【解决方案1】:

我认为问题在于您没有告诉 Azure 您尝试部署的操作系统类型。这是一台经过系统准备的机器,因此需要完成一些后期任务来设置 RDP 等。

我认为您缺少的具体命令是Set-AzureRmVmOperatingSystem

编辑:我看到您正在尝试附加通用 VHD。您需要从图像创建 VHD,而不是附加。见this article.

【讨论】:

  • 感谢您的回答!当我添加以下代码行时: $VMconfig = Set-AzureRmVMOperatingSystem -VM $VMconfig -Windows -ProvisionVMAgent -ComputerName $servername -EnableAutoUpdate 我得到:New-AzureRmVM : 参数 'osProfile' is not allowed.
  • 我更新了答案。如果您已经 sysprep,则需要遵循使用“fromImage”开关而不是“attach”的通用 VHD 部署
  • 没问题。如果对您有帮助,请不要忘记将答案标记为正确。干杯
猜你喜欢
  • 2020-02-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-04
  • 1970-01-01
相关资源
最近更新 更多