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

如何用Azure CLI列出含状态及父管理组的所有订阅信息

解决方法

你可以通过扩展Azure Resource Graph查询,一次性获取订阅名称、ID、状态、标签和父管理组信息,分两种场景提供命令:

场景1:获取父管理组ID(简洁版)

直接从订阅属性中提取所需字段,命令如下:

az graph query -q 'resourcecontainers | where type == "microsoft.resources/subscriptions" | project 订阅名称 = name, 订阅ID = subscriptionId, 状态 = properties.state, 标签 = tags, 父管理组ID = properties.managementGroupId'

场景2:获取父管理组名称(关联查询)

如果需要显示父管理组的名称而非ID,需关联管理组资源数据进行查询,命令如下:

az graph query -q 'resourcecontainers | where type == "microsoft.resources/subscriptions" | project 订阅名称 = name, 订阅ID = subscriptionId, 状态 = properties.state, 标签 = tags, 父管理组ID = properties.managementGroupId | join kind=leftouter (resourcecontainers | where type == "microsoft.management/managementgroups" | project 父管理组ID = id, 父管理组名称 = name) on 父管理组ID'

关键字段说明

  • properties.state:返回订阅的状态,常见值包括Enabled、Disabled、Deleted等
  • properties.managementGroupId:订阅所属父管理组的唯一ID
  • 关联查询使用leftouter join,确保即使订阅未关联管理组(或管理组数据未同步),也不会丢失订阅条目

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 22:04:55