@@ -103,6 +103,7 @@ TO DO.
103
103
104
104
105
105
### List all devices with 2 or more IP addresses
106
+ THIS IS TERRIBLE. Use mv-expand
106
107
```
107
108
Resources
108
109
| where type startswith 'microsoft.network' and isnotempty(properties.ipConfigurations[1])
@@ -194,15 +195,43 @@ Resources
194
195
```
195
196
196
197
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.
197
199
198
200
```
199
201
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
206
235
```
207
236
208
237
0 commit comments