Skip to content

Commit 3c8ee03

Browse files
committed
Update Kusto Graph Explorer Queries.md
1 parent 9cf790a commit 3c8ee03

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

AZURE/Kusto Graph Explorer Queries.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,29 @@ Resources
251251
| project subscriptionName, name, resourceGroup, location, ipCount, privateIPType, privateIP, publicIP, nicNSG, resourceGroupNSG, tags, subnetId, nicId
252252
```
253253

254+
### List all NSG security rules in one query
255+
Courtesy of https://blog.blksthl.com/2020/10/02/list-all-nsg-security-rules-in-one-query-using-azure-resource-graph/
256+
257+
```
258+
Resources
259+
| where type =~ "microsoft.network/networksecuritygroups"
260+
| join kind=leftouter (ResourceContainers | where type=='microsoft.resources/subscriptions' | project SubcriptionName=name, subscriptionId) on subscriptionId
261+
| where resourceGroup == 'production' or resourceGroup == 'testing'
262+
// Only if you don't want to see all, add more resourceGroups as needed: or resourceGroup == 'xxx'
263+
| mv-expand rules=properties.securityRules
264+
| extend direction = tostring(rules.properties.direction)
265+
| extend priority = toint(rules.properties.priority)
266+
| extend description = rules.properties.description
267+
| extend destprefix = rules.properties.destinationAddressPrefix
268+
| extend destport = rules.properties.destinationPortRange
269+
| extend sourceprefix = rules.properties.sourceAddressPrefix
270+
| extend sourceport = rules.properties.sourcePortRange
271+
| extend subnet_name = split((split(tostring(properties.subnets), '/'))[10], '"')[0]
272+
//| where destprefix == '*'
273+
| project SubcriptionName, resourceGroup, subnet_name, name, direction, priority, destprefix, destport, sourceprefix, sourceport, description //, subscriptionId, rules.properties
274+
| sort by SubcriptionName, resourceGroup asc, name, direction asc, priority asc
275+
```
276+
254277

255278
### List all Network Interfaces (NICs) with NSG detail
256279
This lists all NICs with the associated NSG, subnet, subnet NSG,

0 commit comments

Comments
 (0)