View BGP metrics and status

You can view BGP metrics and status by using the Azure portal, or by using Azure PowerShell.

Azure portal

In the Azure portal, you can view BGP peers, learned routes, and advertised routes. You can also download .csv files containing this data.

  1. In the Azure portal, navigate to your virtual network gateway.

  2. Under Monitoring, select BGP peers to open the BGP peers page.

    Screenshot of metrics in the Azure portal.

Learned routes

  1. You can view up to 50 learned routes in the portal.

    Screenshot of learned routes.

  2. You can also download the learned routes file. If you have more than 50 learned routes, the only way to view all of them is by downloading and viewing the .csv file. To download, select Download learned routes.

    Screenshot of downloading learned routes.

  3. Then, view the file.

    Screenshot of downloaded learned routes.

Advertised routes

  1. To view advertised routes, select the ... at the end of the network that you want to view, then click View advertised routes.

    Screenshot showing how to view advertised routes.

  2. On the Routes advertised to peer page, you can view up to 50 advertised routes.

    Screenshot of advertised routes.

  3. You can also download the advertised routes file. If you have more than 50 advertised routes, the only way to view all of them is by downloading and viewing the .csv file. To download, select Download advertised routes.

    Screenshot of selecting downloaded advertised routes.

  4. Then, view the file.

    Screenshot of downloaded advertised routes.

BGP peers

  1. You can view up to 50 BGP peers in the portal.

    Screenshot of BGP peers.

  2. You can also download the BGP peers file. If you have more than 50 BGP peers, the only way to view all of them is by downloading and viewing the .csv file. To download, select Download BGP peers on the portal page.

    Screenshot of downloading BGP peers.

  3. Then, view the file.

    Screenshot of downloaded BGP peers.

PowerShell

Use Get-AzVirtualNetworkGatewayBGPPeerStatus to view all BGP peers and the status.

This article uses PowerShell cmdlets. To run the cmdlets, you can use Azure Cloud Shell. Cloud Shell is a free interactive shell that you can use to run the steps in this article. It has common Azure tools preinstalled and configured to use with your account.

To open Cloud Shell, just select Open Cloudshell from the upper-right corner of a code block. You can also open Cloud Shell on a separate browser tab by going to https://shell.azure.com/powershell. Select Copy to copy the blocks of code, paste them into Cloud Shell, and select the Enter key to run them.

You can also install and run the Azure PowerShell cmdlets locally on your computer. PowerShell cmdlets are updated frequently. If you haven't installed the latest version, the values specified in the instructions may fail. To find the versions of Azure PowerShell installed on your computer, use the Get-Module -ListAvailable Az cmdlet. To install or update, see Install the Azure PowerShell module.

Get-AzVirtualNetworkGatewayBgpPeerStatus -ResourceGroupName resourceGroup -VirtualNetworkGatewayName gatewayName

Asn               : 65515
ConnectedDuration : 9.01:04:53.5768637
LocalAddress      : 10.1.0.254
MessagesReceived  : 14893
MessagesSent      : 14900
Neighbor          : 10.0.0.254
RoutesReceived    : 1
State             : Connected

Use Get-AzVirtualNetworkGatewayLearnedRoute to view all the routes that the gateway has learnt through BGP.

Get-AzVirtualNetworkGatewayLearnedRoute -ResourceGroupName resourceGroup -VirtualNetworkGatewayname gatewayName

AsPath       :
LocalAddress : 10.1.0.254
Network      : 10.1.0.0/16
NextHop      :
Origin       : Network
SourcePeer   : 10.1.0.254
Weight       : 32768

AsPath       :
LocalAddress : 10.1.0.254
Network      : 10.0.0.254/32
NextHop      :
Origin       : Network
SourcePeer   : 10.1.0.254
Weight       : 32768

AsPath       : 65515
LocalAddress : 10.1.0.254
Network      : 10.0.0.0/16
NextHop      : 10.0.0.254
Origin       : EBgp
SourcePeer   : 10.0.0.254
Weight       : 32768

Use Get-AzVirtualNetworkGatewayAdvertisedRoute to view all the routes that the gateway is advertising to its peers through BGP.

Get-AzVirtualNetworkGatewayAdvertisedRoute -VirtualNetworkGatewayName gatewayName -ResourceGroupName resourceGroupName -Peer 10.0.0.254

Rest API

You can also use the GetBgpPeerStatus Rest API call to retrieve the information. This is an Async operation and will return a 202 status code. You need to fetch the results via a separate GET call. For more information, see Azure-AsyncOperation request and response.

Next steps

For more information about BGP, see Configure BGP for VPN Gateway.