So I am trying to create an Azure VM from a VHD (from a server running in Hyper-V) through Powershell. The creation process fails with the following error:
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
I've installed the Azure VM agent onto the virtual machine in Hyper-V. I read the following post about the error, and someone in the comments said you need to allow https to the storage account. I've looked everywhere in the settings, and I'm not sure how to do this. Am I missing something? Could there be another reason it is failing?
In addition, the VM in azure that was created looks like it is running fine, but I can't RDP to it, even though I enabled remote desktop connections before uploading the vhd.
Any help would be greatly appreciated.
Thanks in advance!
Edit: Here is my source code:
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
答案 0 :(得分:0)
我认为问题在于您没有告诉Azure您要尝试部署的操作系统类型。它是一个sysprepped机器,所以有一些后期任务需要完成设置RDP等。
我认为您缺少的具体命令是Set-AzureRmVmOperatingSystem
编辑:我看到你试图附加一个通用的VHD。您需要从图像创建VHD,而不是附加。见this article.