How to List the Network Interface under a Subnet

Shijun Lv 126 Reputation points Microsoft Employee
2024-12-24T02:55:28.23+00:00

Hi Exporters,

May I know how to get the Nic list under a Subnet? Is there any Azure Rest api to do this?

From https://zcusa.951200.xyz/en-us/rest/api/virtualnetwork/network-interfaces/list?view=rest-virtualnetwork-2024-05-01&tabs=HTTP, it seems it can only list by Subscription Resource group level.

Thanks

Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,574 questions
0 comments No comments
{count} votes

Accepted answer
  1. KapilAnanth-MSFT 48,081 Reputation points Microsoft Employee
    2024-12-24T04:31:17.06+00:00

    @Shijun Lv ,

    Welcome to the Microsoft Q&A Platform. Thank you for reaching out & I hope you are doing well.

    Resource are grouped under Subscription and Resource groups - these are the logical groupings in Azure used to get or list resources.

    I am not aware of any REST API to list NICs based on their subnet.

    Instead, you can use Azure Resource Graph

    Resources
    | where type =~ 'microsoft.network/networkinterfaces'
    | project id, ipConfigurations = properties.ipConfigurations
    | mvexpand ipConfigurations
    | project id, subnetId = tostring(ipConfigurations.properties.subnet.id)
    | parse kind=regex subnetId with '/resourceGroups/' resourceGroup '/providers/Microsoft.Network' provider  '/virtualNetworks/' virtualNetwork '/subnets/' subnet
    | where virtualNetwork == "<NAMEOFVNETOFTHESUBNET>" and subnet == "<NAMEOFSUBNET>" and resourceGroup == "<NAMEOFRGOFTHESUBNET>"
    | project id, virtualNetwork, subnet, resourceGroup
    

    And directly download the results as a CSV File.

    Kindly let us know if this helps or you need further assistance on this issue.

    Thanks,

    Kapil


    Please don’t forget to close the thread by clicking "Accept the answer" wherever the information provided helps you, as this can be beneficial to other community members.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.