0
votes

I have been using Powershell to create Winndows Virtual Machine and so far it has worked pretty well. My configuration looks like:

$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize Standard_DS2 | `
Set-AzureRmVMOperatingSystem -Windows -ComputerName $vmName -Credential $Credential | `
Set-AzureRmVMSourceImage -PublisherName MicrosoftWindowsDesktop -Offer Windows-10 `
-Skus RS2-PRO -Version latest | Add-AzureRmVMNetworkInterface -Id $nic.Id | `
Set-AzureRmVmBootDiagnostics -Disable

Now I have changed the -Skus value to RS3-PRO, I am experiencing long delay at step:

New-AzureRmVM -ResourceGroupName $vmResourceGroupName -Location $vmLocation -VM $vmConfig

It has returned error:

New-AzureRmVM : Long running operation failed with status 'Failed'. ErrorCode: VMAgentStatusCommunicationError ErrorMessage: VM 'vmname' 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: 2017-11-15 20:59:34 EndTime: 2017-11-15 21:24:48 OperationID: d1dc18f6-2ac7-4205-b8e6-2fb74fa4cbf9 Status: Failed At C:\pathtoscipt.ps1:144 char:1 + New-AzureRmVM -ResourceGroupName $vmResourceGroupName -Location $vmLo ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [New-AzureRmVM], ComputeCloudException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand

The VM is created though and can be reached via RDP too. Sometimes, the operation succeeds too. I created VM with same image via Azure portal and it got created with no problem. I have following questions:

  1. Does anyone have face similar scenario?

  2. Where should I look for logs about what is happening when the VM is being created.

2
Can you find any error message in Azure portal?Jason Ye
I looked into "Activity Logs" and I can see that VM Creation is succeeded. If I look at status of VM in portal, it states "running" while the powershell prompt is still not returned. Even for a successful creation, it takes quite some time (aprox 20 mins) before it returns the prompt.Muhammad Faizan-Ul-Haq
Yes, it seems powershell wait too long time, please try use this script to create another VM, when wait for the result, please try to type enter to refresh it.Jason Ye
Which version of your Azure PowerShell? Get-Module -ListAvailable -Name Azure -RefreshJason Ye

2 Answers

0
votes

Your script works for me, I can use it to deploy windows 10 to Azure.

enter image description here

Could you please check your Azure portal to check if there any error logs about this deployment?

Where should I look for logs about what is happening when the VM is being created.

Maybe we can check Azure VM agent logs.

Here is the VM agent logs path:C:\WindowsAzure\Logs

enter image description here

Hope this helps.

0
votes

I've faced a similar issue - I managed to solve it by adding the -ProvisionVMAgent and -EnableAutoUpdate flags to Set-AzureRmVMOperatingSystem.

The issue may be caused by the VM Agent not being set up on the new VM, which prevented the VM from reporting back to the script that it had been created.