how to find the subnets in subcription

Alan Phan 0 Reputation points
2024-01-23T16:27:53.6866667+00:00

Doesn't anyone know how to search a subnet is the Azure's subscription

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,721 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Dillon Silzer 57,716 Reputation points
    2024-01-24T00:50:16.0266667+00:00

    Hi Alan,

    I recommend reading the following:

    List all VNet and Subnets across multiple subscriptions

    http://dev.to/roberthstrand/list-all-vnet-and-subnets-across-multiple-subscriptions-4028

    Taken from the blog post by Roberth Strand:

    Get-AzSubscription | Foreach-Object {
        $sub = Set-AzContext -SubscriptionId $_.SubscriptionId
        $vnets = Get-AzVirtualNetwork
    
        foreach ($vnet in $vnets) {
            [PSCustomObject]@{
                Subscription = $sub.Subscription.Name
                Name = $vnet.Name
                Vnet = $vnet.AddressSpace.AddressPrefixes -join ', '
                Subnets = $vnet.Subnets.AddressPrefix -join ', '
            }
        }
    } | Export-Csv -Delimiter ";" -Path "AzureVnet.csv"
    

    The PowerShell script above will get all the subscriptions you have access to and export the VNets from all of the subscriptions.

    If this is helpful please accept answer.

    0 comments No comments

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.