0

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.

Godson
  • 1
  • 1
  • 2

2 Answers2

0

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.

Godson
  • 1
  • 1
  • 2
  • 1
    Hey, did you ever finish the query to fetch all resources that are attached to a particular NSG, if so I would love to take a look. Been trying to figure out the query but struggling. – EG92 Jul 27 '22 at 19:50
0

It is here under Virtual Network.

enter image description here

Smug
  • 167
  • 1
  • 2
  • 9