Skip to content

Commit 24d77cd

Browse files
committed
Update Kusto Graph Explorer Queries.md
1 parent 2697f35 commit 24d77cd

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

AZURE/Kusto Graph Explorer Queries.md

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ TO DO.
103103

104104

105105
### List all devices with 2 or more IP addresses
106+
THIS IS TERRIBLE. Use mv-expand
106107
```
107108
Resources
108109
| where type startswith 'microsoft.network' and isnotempty(properties.ipConfigurations[1])
@@ -194,15 +195,43 @@ Resources
194195
```
195196

196197
As there is a limit of four (4) joins ina kusto resource graph query, we can either return the subscription name or the associated VM name.
198+
The query below lists all wit VM name but without subscription name.
197199

198200
```
199201
Resources
200-
| where type == "microsoft.compute/virtualmachines" and isnotempty(properties.networkProfile.networkInterfaces)
201-
| extend vmName = name,
202-
vmResourceGroup = resourceGroup,
203-
vmSize = tostring(properties.hardwareProfile.vmSize),
204-
osType = tostring(properties.storageProfile.osDisk.osType),
205-
nicId = tostring(properties.networkProfile.networkInterfaces[0].id)
202+
| where type =~ "microsoft.network/networkinterfaces"
203+
| mv-expand ipConfigurations = properties.ipConfigurations
204+
| extend ipCount = array_length(properties.ipConfigurations)
205+
| extend privateIPType = tostring(ipConfigurations.properties["privateIPAllocationMethod"])
206+
| extend privateIP = tostring(ipConfigurations.properties["privateIPAddress"])
207+
| extend subnetId = tostring(ipConfigurations.properties.subnet["id"])
208+
| extend publicIPid = tostring(ipConfigurations.properties["publicIPAddress"].id)
209+
| extend nicId = tostring(id)
210+
| join kind=leftouter (Resources
211+
| where type contains 'publicIPAddresses' and isnotempty(properties.ipAddress)
212+
| extend publicIP = tostring(properties.ipAddress),
213+
publicIPid = tostring(id)) on publicIPid
214+
| join kind=leftouter (Resources | where type == "microsoft.network/networksecuritygroups"
215+
| mv-expand nics = properties.networkInterfaces
216+
| extend nicId = tostring (nics.id),
217+
nicNSG = name,
218+
nicNSGgroup = resourceGroup ) on nicId
219+
| join kind=leftouter (Resources
220+
| where type == "microsoft.compute/virtualmachines" and isnotempty(properties.networkProfile.networkInterfaces)
221+
| extend vmName = name
222+
| extend vmSize = tostring(properties.hardwareProfile.vmSize)
223+
| extend osType = tostring(properties.storageProfile.osDisk.osType)
224+
| mv-expand nics = properties.networkProfile.networkInterfaces
225+
| extend nicId = tostring (nics.id) ) on nicId
226+
| join kind=leftouter (Resources | where type == "microsoft.network/networksecuritygroups"
227+
| mv-expand subnets = properties.subnets
228+
| extend subnetId = tostring(subnets.id),
229+
vnetName = split(tostring(subnets.id),'/')[8],
230+
subnetName = split(tostring(subnets.id),'/')[10],
231+
subnetNSG = name,
232+
subnetNSGgroup = resourceGroup
233+
) on subnetId
234+
| project subscriptionId, nicName=name, resourceGroup, vmName, vmSize, osType, vnetName, subnetName, nicNSG, subnetNSG, location, ipCount, privateIPType, privateIP, publicIP, tags, subnetId, nicId
206235
```
207236

208237

0 commit comments

Comments
 (0)