Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure 打印子网中的所有VM名称和专用IP_Azure_Azure Resource Graph - Fatal编程技术网

Azure 打印子网中的所有VM名称和专用IP

Azure 打印子网中的所有VM名称和专用IP,azure,azure-resource-graph,Azure,Azure Resource Graph,我想列出在特定子网(例如,名为“sub-a”)下包含私有IP地址的所有虚拟机名称。我该怎么做 我希望Azure资源图浏览器中的此查询至少可以打印所有非空的私有IP地址: Resources | where type =~ 'microsoft.compute/virtualmachines' and isnotempty(properties.privateIPAddress) 您需要查看网络接口并展开属性以提取专用IP地址。像这样的东西应该能奏效。我修改了我们的一个应用程序,将私有IP改为公

我想列出在特定子网(例如,名为“sub-a”)下包含私有IP地址的所有虚拟机名称。我该怎么做

我希望Azure资源图浏览器中的此查询至少可以打印所有非空的私有IP地址:

Resources
| where type =~ 'microsoft.compute/virtualmachines' and isnotempty(properties.privateIPAddress)

您需要查看网络接口并展开属性以提取专用IP地址。像这样的东西应该能奏效。我修改了我们的一个应用程序,将私有IP改为公共IP

 Resources
| where type =~ 'microsoft.compute/virtualmachines'
| extend nics=array_length(properties.networkProfile.networkInterfaces)
| mv-expand nic=properties.networkProfile.networkInterfaces
| where nics == 1 or nic.properties.primary =~ 'true' or isempty(nic)
| project vmId = id, vmName = name, vmSize=tostring(properties.hardwareProfile.vmSize), nicId = tostring(nic.id)
| join kind=leftouter (
    Resources
    | where type =~ 'microsoft.network/networkinterfaces'
    | extend ipConfigsCount=array_length(properties.ipConfigurations)
    | extend subnet = tostring(properties.ipConfigurations[0].properties.subnet) 
    | mv-expand ipconfig=properties.ipConfigurations
    | where ipConfigsCount == 1 or ipconfig.properties.primary =~ 'true'
    | project nicId = id, subnet, privateIp = tostring(ipconfig.properties.privateIPAddress))
on nicId
    | order by subnet asc

非常感谢。但是如何筛选,使其仅显示属于名为“sub-a”的子网的子网?我更新为按子网ID排序。这是我能快速完成的最好操作,子网名称是完整GUID,因此不容易筛选。好的,也可以。非常感谢。