如何查询“天蓝色状态"?使用powershell [英] How can I query "Azure Status" using powershell

查看:135
本文介绍了如何查询“天蓝色状态"?使用powershell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用PowerShell查询天蓝色状态"?

How can I query "Azure Status" using PowerShell?

https://azure.microsoft.com/en-in/status/

我们有一个自动化逻辑,并且我们想通过检查Azure服务是否出现中断来进行即兴发挥.如果没有中断,请继续进行自动化.

We have a automation logic in place, and we want to improvise by having a check that checks if the Azure service is having an outage. If there is no outage, then continue with the automation.

推荐答案

AFAIK,没有PowerShell或Rest API可以获取Azure状态.我能找到的最接近的是资源健康状况.

AFAIK, there is no PowerShell or Rest API to get the Azure status. The closest I can find is to get the Resource Health.

链接说,

Resource Health提供的信息比Azure状态或Service Health仪表板提供的信息更具体.

The information provided by Resource Health is more specific than what is provided by Azure status or the Service Health dashboard.

Azure状态和服务运行状况"仪表板会通知您有关影响广泛客户(例如Azure区域)的服务问题,而资源运行状况则公开了仅与特定资源相关的更详细的事件.例如,如果主机意外重启,则资源运行状况仅警报那些虚拟机正在该主机上运行的客户.

Whereas Azure status and the Service Health dashboard inform you about service issues that affect a broad set of customers (for example an Azure region), Resource Health exposes more granular events that are relevant only to the specific resource. For example, if a host unexpectedly reboots, Resource Health alerts only those customers whose virtual machines were running on that host.

此外,也没有内置的Powershell来获取资源运行状况.如果要通过Powershell获得它,则可以尝试调用其余的api Invoke-RestMethod .

Also, there is also no built-in powershell to get the Resource Health. If you want to get it via powershell, you could try to call the rest api Availability Statuses - List By Subscription Id via Invoke-RestMethod.

示例:

$url = "https://management.azure.com/subscriptions/{subscription-id}/providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2015-01-01"
$accesstoken = "eyJ0eXAixxxxxxxxxxxxx4qPcZfMJNLGRLOMeIncWnFnKWA"
$header = @{
    'Authorization' = 'Bearer ' + $accesstoken
}

Invoke-RestMethod –Uri $url –Headers $header –Method GET | ConvertTo-Json

要在上面的命令中获取$accesstoken,最简单的方法是单击

To get the $accesstoken in the command above, the easiest way is to click the Try it button in the doc, login and copy the token.

如果您不希望这样,也可以使用azure广告

If you don't want this way, you can also use azure ad client credential flow to generate the access token. Here is a sample, you could refer to it. Don't forget to change the $ARMResource to https://management.azure.com/.

这篇关于如何查询“天蓝色状态"?使用powershell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆