文章“【Azure Developer】在Azure Resource Graph Explorer中查看当前订阅下的所有资源信息列表并导出(如VM的名称,IP地址内网/公网,OS,区域等) ”的另一个示例。

使用Azure Resource Graph查询:把这订阅(Subscription ID)下的VM虚拟机和相关磁盘信息拉取一下数据(VM名字,VM的tag,VM的资源ID,硬盘名字,硬盘大小,磁盘的资源ID)

 

问题答案

根据Azure Resource Graph Explorer中提供的Resources表来查看VM的相关信息。而磁盘相关的信息处于 properties.storageProfile.osDisk 以及 properties.storageProfile.dataDisks中。

示例查询语句为:

resources
| where type =~ 'microsoft.compute/virtualmachines'
| extend  osDisk = properties.storageProfile.osDisk, disks = properties.storageProfile.dataDisks
| project  name, tags, id, osDisk.name, osDisk.diskSizeGB, osDisk.managedDisk.id, 
disks[0].name, disks[0].diskSizeGB, 
disks[1].managedDisk.id, disks[1].name, disks[1].diskSizeGB, disks[1].managedDisk.id,
disks[2].name, disks[2].diskSizeGB,disks[2].managedDisk.id

查询结果示例:

【Azure Developer】使用Azure Resource Graph的查询语法的示例

 

 

参考文档:

https://docs.microsoft.com/en-us/azure/governance/resource-graph/samples/samples-by-category?tabs=azure-cli#azure-virtual-machines

Query operators : https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/queries

相关文章:

  • 2021-09-08
  • 2021-07-20
  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2021-08-07
  • 2022-01-21
  • 2021-11-15
猜你喜欢
  • 2021-05-27
  • 2022-01-26
  • 2021-09-10
  • 2021-12-31
  • 2022-01-21
  • 2022-01-27
  • 2021-06-18
相关资源
相似解决方案