You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure虚拟机状态显示错误咨询:实际运行却显示启动中

Azure虚拟机状态显示异常:频繁出现空状态或“VM starting”但实际未重启

我写了个每分钟获取Azure虚拟机运行状态的PowerShell脚本,用来验证VM是否偶尔上报错误状态。脚本显示该VM每天会多次出现持续数分钟的空状态或“VM starting”提示,但VM实际根本没重启,Azure Monitoring里一直显示它处于运行状态。我们的Prometheus/Grafana监控栈里,多数虚拟机都存在这个问题。我已经给微软支持提交了问题和截图,但对方说没发现异常。

该虚拟机上次重启时间是2024-01-24。另外,我在Azure Kubernetes集群中运行的Prometheus数据采集Python脚本也出现了同样的错误。想问问有没有其他用户遇到过这类问题?我希望Azure门户和API能始终显示正确的VM状态。

PowerShell脚本

Set-AzContext -Subscription '<Subscription>'
while ($true) {
    try {
        $Date = $(get-date).ToString()
        $VM = Get-AzVM -ResourceGroupName '<Resource group>' -Name '<VM name>' -Status
        if ($VM.Statuses[1].DisplayStatus -ne 'VM running') {
            Write-Output ($Date + "  " + $VM.Statuses[1].DisplayStatus)
        }
    }
    catch {
        Write-Output ($(get-date).ToString() + "  " + $VM.Name)
        $errorMessage = $_.Exception.Message
        $line = $_.InvocationInfo.ScriptLineNumber
        Write-Output "Unexpected exception: $errorMessage at $line"
    }
    Start-Sleep -Seconds 60
}

最近24小时脚本输出

2024-02-20 09:56:29
2024-02-20 10:07:04
2024-02-20 21:21:01
2024-02-21 03:29:14
2024-02-21 03:30:44
2024-02-21 03:32:15
2024-02-21 03:33:52
2024-02-21 03:35:30
2024-02-21 03:37:00  VM starting
2024-02-21 03:38:01  VM starting
2024-02-21 03:39:02  VM starting
2024-02-21 03:40:07  VM starting
2024-02-21 03:41:08  VM starting
2024-02-21 03:42:08  VM starting

内容的提问来源于stack exchange,提问作者Rudhan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 13:05:57