1
1
# Kusto Graph Explorer Queries
2
2
The Resource Graph queries can be done through PowerShell or via the Azure Portal under "Resource Graph Explorer".
3
+ See also: https://docs.microsoft.com/en-us/azure/governance/resource-graph/samples/starter?tabs=azure-cli
3
4
4
5
5
6
### LIST ALL SUBSCRIPTIONS ###
@@ -18,17 +19,65 @@ Resources
18
19
| limit 25
19
20
```
20
21
21
- ### LIST ALL NICs with Public and Private IP addresses along with their associated VM and subscription
22
+ ### List VMs with detail (excluding IP info)
22
23
```
23
24
Resources
24
- | where type =~ "microsoft.network/networkinterfaces"
25
- and properties.ipConfigurations[0[.properties.privateIPAddress =~ "10.71.2.2"
26
- | extend privateIPType = tostring(properties.ipCOnfigurations[0].properties["privateIPAllocationMethod2])
25
+ | where type == "microsoft.compute/virtualmachines" and isnotempty(properties.networkProfile.networkInterfaces)
26
+ | extend vmSize = tostring(properties.hardwareProfile.vmSize)
27
+ | extend osType = tostring(properties.storageProfile.osDisk.osType)
28
+ | extend nicId = properties.networkProfile.networkInterfaces[0].id
29
+ | join kind=leftouter (ResourceContainers | where type=~'microsoft.resources/subscriptions'
30
+ | project subscriptionName=name, subscriptionId) on subscriptionId
31
+ | project name, resourceGroup, subscriptionName, location, osType, privateIP, publicIP, vmSize, tags, id
32
+ ```
33
+
34
+ ### List VMs with detail (including IP info)
35
+ Note that resource graph is NOT always up to date with dynamically assigned public IP addresses.
36
+ A VM can be running for quite a long time before the public IP address displays in resource graph.
37
+
38
+ ```
39
+ Resources
40
+ | where type == "microsoft.compute/virtualmachines" and isnotempty(properties.networkProfile.networkInterfaces)
41
+ | extend vmSize = tostring(properties.hardwareProfile.vmSize)
42
+ | extend osType = tostring(properties.storageProfile.osDisk.osType)
43
+ | extend nicId = tostring(properties.networkProfile.networkInterfaces[0].id)
44
+ | extend vmProperties = tostring(properties)
45
+ | join kind=leftouter (Resources
46
+ | where type =~ "microsoft.network/networkinterfaces"
47
+ | extend privateIP = tostring(properties.ipConfigurations[0].properties["privateIPAddress"])
48
+ | extend pubId = tostring(properties.ipConfigurations[0].properties.publicIPAddress.id)
49
+ | extend subnetId = tostring(properties.ipConfigurations[0].properties.subnet.id)
50
+ | join kind=leftouter (Resources | where type =~ "microsoft.network/publicipaddresses"
51
+ | extend fqdn = properties.dnsSettings.fqdn
52
+ | extend publicIP = tostring(properties.ipAddress) // May not be up to date...
53
+ | project pubId=id, publicIP, fqdn, pubIpProperties=properties) on pubId
54
+ | project nicId=id, nicName=name, privateIP, publicIP, fqdn, pubId, nicProperties=properties, pubIpProperties) on nicId
55
+ | join kind=leftouter (ResourceContainers | where type=~'microsoft.resources/subscriptions'
56
+ | project subscriptionName=name, subscriptionId) on subscriptionId
57
+ | project name, resourceGroup, subscriptionName, location, osType, vmSize, nicName, privateIP, publicIP, fqdn, nicProperties, pubIpProperties, vmProperties, id
58
+ ```
59
+
60
+
61
+ ### LIST ALL NICs with Public and Private IP addresses abd FQDNs
62
+ Note that resource graph is NOT always up to date with dynamically assigned public IP addresses.
63
+ A VM can be running for quite a long time before the public IP address displays in resource graph.
64
+
65
+ ```
66
+ Resources
67
+ | where type =~ "microsoft.network/networkinterfaces"
27
68
| extend privateIP = tostring(properties.ipConfigurations[0].properties["privateIPAddress"])
28
- | extend publicIP = tostring(properties.ipConfigurations[0].properties["publicIPAddress"])
29
- | extend subnet = tostring(properties.ipConfigurations[0].properties.subnet["id"])
69
+ | extend pubId = tostring(properties.ipConfigurations[0].properties.publicIPAddress.id)
70
+ | extend subnetId = tostring(properties.ipConfigurations[0].properties.subnet.id)
71
+ | join kind=leftouter (Resources | where type =~ "microsoft.network/publicipaddresses"
72
+ | extend fqdn = properties.dnsSettings.fqdn
73
+ | extend publicIP = tostring(properties.ipAddress) // May be out of date...
74
+ | project pubId=id, publicIP, fqdn, pubIpProperties=properties) on pubId
75
+ | project nicId=id, nicName=name, privateIP, publicIP, fqdn, pubId, pubIpProperties
30
76
```
31
77
78
+ ### List all NICs with the associuated VMs
79
+ TO DO.
80
+
32
81
### List all devices with 2 or more IP addresses
33
82
```
34
83
Resources
0 commit comments