通过Azure资源图查询获得与子网相关联的Azure资源

发布于 2025-01-21 19:26:59 字数 490 浏览 5 评论 0原文

我希望获取与子网相关的所有资源。我可以找到参考oh如何以相反的方式进行操作(获取特定资源,其中包括与之关联的子网),但找不到任何文档,我们可以在其中获取与子网相关的所有资源。

我的最终目标是获取使用特定网络安全组的所有Azure资源。这使我提出了上述问题。

从另一个问题中,我了解我可以使用REST API获取特定虚拟网络的详细信息。 如何检查使用Fluent API或管理API在Azure中分配的另一个资源的子网?。如果有人建议任何人都能实现这一目标,我将不胜感激。

提前致谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

女中豪杰 2025-01-28 19:26:59

它在虚拟网络下。

It is here under Virtual Network.

enter image description here

浅笑轻吟梦一曲 2025-01-28 19:26:59

如果将来有人需要这个时间。我刚刚运行了此查询,以获取与特定子网相关的Azure资源列表。结果是提供资源名称,组,位置和其他有用信息的表。

resources
| where type == 'microsoft.network/networkinterfaces'
| extend subnetId = properties.ipConfigurations[0].properties.subnet.id,
            privateEndpoint = tostring(properties.privateEndpoint.id)
| where subnetId == '/subscriptions/<subId>/resourceGroups/<rgName>/providers/Microsoft.Network/virtualNetworks/<vnetName>/subnets/<snetName>'
| project id, name, type, kind, location, resourceGroup,subnetId, privateEndpoint, properties
| extend azureResourceId = iff(isempty( privateEndpoint ), tostring(properties.virtualMachine.id), '')
| project id, name, type, kind, location, resourceGroup, subnetId, privateEndpoint,azureResourceId, properties
| join kind=leftouter (
    resources
    | where type == 'microsoft.network/privateendpoints'
    | project azureResourceIdPe = properties.privateLinkServiceConnections[0].properties.privateLinkServiceId, id
    ) on $left.privateEndpoint == $right.id
| extend azureResourceId = coalesce(azureResourceId, azureResourceIdPe)
| project id, name, type, kind, location, resourceGroup, subnetId, privateEndpoint, properties, azureResourceId
| join kind=leftouter (
    resources
    | project id, azureResourceName = name, azureResourceType = type, azureResourceRg = resourceGroup, azureResourceLocation = location
    ) on $left.azureResourceId == $right.id
| project id, name, type, kind, location, resourceGroup, subnetId, privateEndpoint, azureResourceId, azureResourceName, azureResourceType, azureResourceRg, azureResourceLocation, properties

In case someone some time in the future needs this. I have just ran this query to get list of Azure resources associated with a specific subnet. The result is a table providing resource name, group, location and other useful info.

resources
| where type == 'microsoft.network/networkinterfaces'
| extend subnetId = properties.ipConfigurations[0].properties.subnet.id,
            privateEndpoint = tostring(properties.privateEndpoint.id)
| where subnetId == '/subscriptions/<subId>/resourceGroups/<rgName>/providers/Microsoft.Network/virtualNetworks/<vnetName>/subnets/<snetName>'
| project id, name, type, kind, location, resourceGroup,subnetId, privateEndpoint, properties
| extend azureResourceId = iff(isempty( privateEndpoint ), tostring(properties.virtualMachine.id), '')
| project id, name, type, kind, location, resourceGroup, subnetId, privateEndpoint,azureResourceId, properties
| join kind=leftouter (
    resources
    | where type == 'microsoft.network/privateendpoints'
    | project azureResourceIdPe = properties.privateLinkServiceConnections[0].properties.privateLinkServiceId, id
    ) on $left.privateEndpoint == $right.id
| extend azureResourceId = coalesce(azureResourceId, azureResourceIdPe)
| project id, name, type, kind, location, resourceGroup, subnetId, privateEndpoint, properties, azureResourceId
| join kind=leftouter (
    resources
    | project id, azureResourceName = name, azureResourceType = type, azureResourceRg = resourceGroup, azureResourceLocation = location
    ) on $left.azureResourceId == $right.id
| project id, name, type, kind, location, resourceGroup, subnetId, privateEndpoint, azureResourceId, azureResourceName, azureResourceType, azureResourceRg, azureResourceLocation, properties
我的痛♀有谁懂 2025-01-28 19:26:59

我自己找到了答案:p。您可以在子网详细信息中获得关联的设备以及有关获取VirtualNetworks的其他详细信息。

资源图查询:

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

属性 - &gt; subnets-&gt; properties-&gt; ipconfigurations

ipconfigurations是连接的设备。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文