How To List All VNET Subnets Used for Private Endpoints of App service using PowerShell Script
Published Apr 27 2023 07:14 PM 3,440 Views

Azure App service can enable Private Endpoints for inbound traffic. 

Customers may want to list all VNET subnets used for Private Endpoints, and enable Network Security Group for the Private Endpoints.

There is no way to do it from Azure portal. But the below Power shell script can help customers list all the subnets used for Private Endpoints.


  • List all VNET subnets used for Private Endpoint using PowerShell script

$privateEndpoints = Get-AzPrivateEndpoint

$subnetIds = $privateEndpoints | ForEach-Object { $_.Subnet.Id }

$uniqueSubnetIds = $subnetIds | Sort-Object -Unique


foreach ($subnetId in $uniqueSubnetIds) {

    Get-AzResource -ResourceId $subnetId



The output is like this 



  • Regarding more parameters for Get-AzPrivateEndpoint

         Check Get-AzPrivateEndpoint (Az.Network) | Microsoft Learn


Version history
Last update:
‎Apr 27 2023 07:14 PM
Updated by: