|
1 | 1 | // Azure Resource Graph Query |
2 | 2 | // This query will validate the subnet id for an appGW ends with a /24 |
3 | | - |
4 | 3 | resources |
5 | | -| where type =~ 'Microsoft.Network/applicationGateways' |
6 | | -| extend subnetid = tostring(properties.gatewayIPConfigurations[0].properties.subnet.id) |
7 | | -| join kind=leftouter(resources |
| 4 | +| where type == "microsoft.network/applicationgateways" |
| 5 | +| extend subnetId = tostring(properties.gatewayIPConfigurations[0].properties.subnet.id) |
| 6 | +| project id, subscriptionId, subnetId, name, tags |
| 7 | +| join ( |
| 8 | + resources |
8 | 9 | | where type == "microsoft.network/virtualnetworks" |
9 | | - | mv-expand properties.subnets |
10 | | - | extend subnetid = tostring(properties_subnets.id) |
11 | | - | extend addressprefix = tostring(properties_subnets.properties.addressPrefix) |
12 | | - | project subnetid, addressprefix) on subnetid |
13 | | -| where addressprefix !endswith '/24' |
14 | | -| project recommendationId = "8364fd0a-7c0e-e240-9d95-4bf965aec243", name, id, tags, param1 = strcat('AppGW subnet prefix: ', addressprefix) |
15 | | - |
| 10 | + | project id, subnets = properties.subnets |
| 11 | + | mv-expand subnets |
| 12 | + | mv-expand subnets.properties.addressPrefixes |
| 13 | + | project |
| 14 | + id, |
| 15 | + subnetId = tostring(subnets.id), |
| 16 | + prefix1 = subnets.properties.addressPrefix, |
| 17 | + prefix2 = subnets.properties.addressPrefixes |
| 18 | + | mv-expand prefix2 |
| 19 | + | extend prefix = iff(isnotnull(prefix1), prefix1, prefix2) |
| 20 | + | extend subnetPrefixLength = split(prefix, "/")[1] |
| 21 | +) on subnetId |
| 22 | +| where subnetPrefixLength > 24 and subnetPrefixLength != 64 |
| 23 | +| project recommendationId = "8364fd0a-7c0e-e240-9d95-4bf965aec243",name,id,tags,param1 = strcat("AppGW subnet prefix: ", prefix) |
0 commit comments