Sometimes, if extensions take more time than expected the VM state show unknows. But the extensions at background still continue to install and after extensions installation success, the vm status shows running
Unknown powerstate status for Azure VM
I have a powershell script that starts up a sequence of Azure VMs by:
- Starting up a VM
- Checking if the powerstate of the VM is running
- Moving onto the next VM in the list
As of recently, VMs that are in the South Central US region seem to stick on the "Unknown" status and then script is stuck waiting for the status to update to running, and this could last from 5-60 mins.
The major issue is these machines need to be on by a certain time.
Is there any way around this?
4 answers
Sort by: Most helpful
-
-
Limitless Technology 39,601 Reputation points
2021-12-17T15:34:39.513+00:00 I find it interesting that you consult the main common errors within Azure, so you will know the cause and how to solve them.
See these errors in the article link below:
https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/error-messages
----
--If the answer is helpful, please vote positively and accept the answer.--
-
msrini-MSFT 9,281 Reputation points Microsoft Employee
2021-11-10T16:54:17.613+00:00 To identify what is the cause of status returned as "unknown" needs deeper investigation with the logs from your end. That requires a support ticket.
For now, to mitigate your issue, you can change the logic. You can skip the second step to check the Powerstate running and proceed further. Once this script ran successfully, you can get the status of all the VMs which this script turns ON and if it is unknown, keep on checking the status every 30 mins till it show as running.
The above suggestion is only a workaround, if you need to get a deeper investigation, proceed with the support ticket.
Regards,
Karthik Srinivas -
shiva patpi 13,251 Reputation points Microsoft Employee
2021-11-10T16:59:08.22+00:00 Hello @cmcardle ,
As I don't have the commands/script which you are using , one of the suggestion is - If there is no dependency among the machines start sequence , can you try to start the machines first with out checking the status of the VMs and in the next iteration come back and do a status check. This way all the VMs will be started on time.Try out the below sample script:-
try
{
$StartScriptBlock =
{
param($VMName,$RGName)
Write-Host "Starting VM: " $VMName
try{
Start-AzVM -ResourceGroupName $RGName -Name $VMName -NoWait
}
catch{
Write-Host "Error in Starting VM: " $VMName
}
}$StatusScriptBlock =
{
param($VMName,$RGName)
Write-Host "Starting VM: " $VMName
try{
$status = Get-AzVM -ResourceGroupName $RGName -Name $VMName
Write-Host $VMName ":" $status.ProvisioningState
}
catch{
Write-Host "Error in Starting VM: " $VMName
}
}$StartVMJobs = @();
$StatusVMJobs = @();
$AllVMs = Get-AzVM
#start all the machines
foreach ($vm in $AllVMs)
{
$StartVMJobs += Start-Job -ScriptBlock $StartScriptBlock -ArgumentList $vm.Name,$vm.ResourceGroupName
$StatusVMJobs += Start-Job -ScriptBlock $StatusScriptBlock -ArgumentList $vm.Name,$vm.ResourceGroupName
}
Write-Host "VM Start Jobs Started successfully"
Wait-Job -Job $StartVMJobs | Out-Null
Receive-Job -Job $StartVMJobs
Write-Host "VM Start Jobs Completed successfully"Write-Host "VM Status Jobs Started successfully"
Wait-Job -Job $StatusVMJobs | Out-Null
Receive-Job -Job $StatusVMJobs
Write-Host "VM Status Jobs Completed successfully"
}
finally
{}
Regards,
Shiva.