Skip to content

Commit 35467a4

Browse files
committed
Update Kusto Graph Explorer Queries.md
1 parent 4d2b78d commit 35467a4

File tree

1 file changed

+55
-6
lines changed

1 file changed

+55
-6
lines changed

AZURE/Kusto Graph Explorer Queries.md

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Kusto Graph Explorer Queries
22
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
34

45

56
### LIST ALL SUBSCRIPTIONS ###
@@ -18,17 +19,65 @@ Resources
1819
| limit 25
1920
```
2021

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)
2223
```
2324
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"
2768
| 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
3076
```
3177

78+
### List all NICs with the associuated VMs
79+
TO DO.
80+
3281
### List all devices with 2 or more IP addresses
3382
```
3483
Resources

0 commit comments

Comments
 (0)