gpt4 book ai didi

powershell - Azure Powershell - 如何获取资源状态

转载 作者:行者123 更新时间:2023-12-03 03:00:15 24 4
gpt4 key购买 nike

我有多个 Microsoft.ApiManagement/service 类型的资源。

当我使用下面的 find cmdlet 与该资源类型时,它不会返回资源的状态/状态。我可以在门户上查看状态,但正在按资源类型检索资源状态,以获取可钻取的摘要仪表板的数据。 -资源类型“microsoft.web/sites”按预期工作并显示资源的状态。

我不确定是否需要为 -ResourceType "Microsoft.ApiManagement/service"执行其他操作才能使其显示状态。-ResourceType "Microsoft.Storage/storageAccounts"也不显示状态,但在门户中显示 Primary:Available、Secondary:Available。似乎每种资源类型都有其一组已定义的属性,并且必须查找文档来遍历该资源类型才能找到需要的内容。我不知道在哪里可以找到这些信息。

谢谢!

Find-AzureRmResource -ResourceType "microsoft.web/sites"  -ExpandProperties |Sort SiteName
Find-AzureRmResource -ResourceType "Microsoft.ApiManagement/service" -ExpandProperties |Sort Name
Find-AzureRmResource -ResourceType "Microsoft.Storage/storageAccounts" -ExpandProperties |Sort Name

最佳答案

如果我的理解是正确的,您可以使用以下命令。

$api=Get-AzureRmResource -ResourceType "Microsoft.ApiManagement/service" -ResourceGroupName shuapi5 -ResourceName shuiapi
$api.Properties.provisioningState

我在实验室进行了测试,它对我有用。

PS C:\Users\v-shshui> $api=Get-AzureRmResource -ResourceType "Microsoft.ApiManagement/service" -ResourceGroupName shuapi5 -ResourceName shuiapi
PS C:\Users\v-shshui> $api.Properties.provisioningState
Activating

关于powershell - Azure Powershell - 如何获取资源状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49593983/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com