'Get Azure resources associated with a subnet through Azure Resource Graph Query

I am looking to fetch all resources associated with a subnet. I could find references oh how to do it the other way around (fetch a particular resource and it includes the subnet it is associated with), but can't find any documents where we can fetch all resources linked with a subnet.

My ultimate goal is to fetch all azure resources which use a particular network security group. That led me to the above question.

From another question I understand I can use a REST Api to get details for a specific virtual network. How to check is subnet allocated with another resource in azure using Fluent API or management API?. I would appreciate if someone could suggest anyway to achieve this.

Thanks in advance.



Solution 1:[1]

Found the answer myself :p. You get the associated devices within the subnet details along with other details on getting virtualnetworks.

Resource graph query:

resources
| where type =~ "microsoft.network/virtualnetworks"

properties->subnets->properties->ipConfigurations

The ipConfigurations are the connected devices.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Godson