New-AzureRmVM:长时间运行操作失败,状态为“Failed”ErrorCode:VMAgentStatusCommunicationError

powershell azure

3181 观看

1回复

所以我试图通过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中的虚拟机上。我阅读了以下有关错误的帖子,评论中有人说您需要允许https到存储帐户。我在设置中到处都是,我不知道该怎么做。我错过了什么吗?还有其他原因导致失败吗?

此外,创建的Azure中的VM看起来运行正常,但我无法对它进行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
作者: Jesse Russell 的来源 发布者: 2019 年 9 月 10 日

回应 (1)


0

决定

我认为问题在于您没有告诉Azure您要尝试部署的操作系统类型。它是一个sysprepped机器,所以有一些后期任务需要完成设置RDP等。

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

编辑:我看到你正在尝试附加一个通用的VHD。您需要从图像创建VHD,而不是附加。看到这篇文章。

作者: CtrlDot 发布者: 26.04.2017 12:47
32x32