Hi
Thanks for reaching out.
Could you please try the following query.
Resources | where type =~ 'Microsoft.Network/networkInterfaces' | extend vnetId = tostring(properties.ipConfigurations[0].properties.subnet.id) | where vnetId has 'YOUR_VNET_NAME' | project id, name, type, location, resourceGroup
and pass this query as body of the post request at following API end point
POST https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2021-03-01
Below is the sample code in python
import requests
import json
query = { "query":
"Resources
| where type =~ 'Microsoft.Network/networkInterfaces' | extend vnetId = tostring(properties.ipConfigurations[0].properties.subnet.id) | where vnetId has 'YOUR_VNET_NAME' | project id, name, type, location, resourceGroup"
}
url = 'https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2021-03-01'
headers = { 'Authorization':f'Bearer {access_token}',
'Content-Type':'application/json'}
response = requests.post(url, headers=headers, data=json.dumps(query))
if
response.status_code == 200:
resources = response.json() print("Resources
in the VNet:")
for
resource in
resources['data']:
print(resource)
else:
print(f"Error:{response.status_code}")
print(response.json())
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".