I am using Azure Web App services, which have configured virtual network integration with an outbound subnet:
I would like to list all resources which are associated with given subnet: "snet-dev". I have created a query and run in the Azure Resource Graph Explorer:
query is:
Resources
| where type =~ "microsoft.network/networkinterfaces"
| extend subnetId = tostring(properties.ipConfigurations[0].properties.subnet.id)
| where subnetId contains "snet-dev"
| project id, name, resourceGroup, location, subnetId
Unfortunately no results are fetched. I have tried to run the query without the "where" but then I am getting far to many results to manualy find the resources with given subnet.
How to write a query which will return all linked resources to a given subnet?
I have few Azure Web App services configured virtual network integration with an outbound subnet named "snet-dev" like this:
Initially, I too got null results when I ran same query as you in my environment like this:
Resources
| where type =~ "microsoft.network/networkinterfaces"
| extend subnetId = tostring(properties.ipConfigurations[0].properties.subnet.id)
| where subnetId contains "snet-dev"
| project id, name, resourceGroup, location, subnetId
Response:
To retrieve all Azure Web App resources under subnet named "snet-dev" using Azure Resource Graph Explorer, you can run below query:
resources
| where type =~ "microsoft.web/sites" // Search for Azure Web Apps
| extend subnetID = tostring(properties.virtualNetworkSubnetId)
| where isnotempty(subnetID)
| extend extractedSubnetName = tostring(split(subnetID, '/')[10]) // Extract subnet name from the full virtualNetworkSubnetId path
| where extractedSubnetName == "snet-dev"
| project webAppId = id, webAppName = name, subnetID, extractedSubnetName
Response: