英文:
Kusto get resourcegroups and subscription information
问题
如何获取所有资源组的资源组名称、订阅名称和ID?
我可以使用以下方式获取所有资源组:
Resources| distinct resourceGroup
但如果我在其中添加"id",我会多次获得相同的资源组。
Resources | distinct resourceGroup, id
英文:
How can I get resource group name, subscription name and id for all the resource groups?
I can get all resourcegroups with
Resources| distinct resourceGroup
But if I add "id" in there I get same resourcegroup multiple times.
Resources | distinct resourceGroup, id
答案1
得分: 1
我明白了,您想使用资源图探索器提取订阅名称、资源组名称和ID。您可以使用以下的KQL查询:
resourcecontainers
| where type == "microsoft.resources/subscriptions"
| join ( resourcecontainers | where type == "microsoft.resources/subscriptions/resourcegroups") on subscriptionId
| distinct name,name1,id1
| project SubscriptionName=name,resourceGroupName=name1, resourceGroupId=id1
注意:这是您提供的代码段的翻译。
英文:
I understand, you want to pull the subscription Name, resource group name, id using the resource graph explorer. you can use the below KQL query.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
resourcecontainers
| where type == "microsoft.resources/subscriptions"
| join ( resourcecontainers | where type == "microsoft.resources/subscriptions/resourcegroups") on subscriptionId
| distinct name,name1,id1
| project SubscriptionName=name,resourceGroupName=name1, resourceGroupId=id1
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论