It can be a little tedious having to use the GUI to fetch routing information and other details for Express Routes. I haven’t actually located a GUI function to revise the Virtual Network Gateway routes.
I’ve used the Get-AzResource command to dynamically ascertain whether or not there is a Virtual Network Gateway and/or Express Route Circuit. In order to review the route table of the Virtual Network Gateway I’ve used the Az module Get-AzVirtualNetworkGatewayLearnedRoute & Get-AzVirtualNetworkGatewayBGPPeerStatus commands. To gather Express Route details I used Get-AzExpressRouteCircuit, Get-AzExpressRouteCircuitARPTable & Get-AzExpressRouteCircuitRouteTable. The script is setup to fetch details for both Private Peering and Microsoft Peering, so if either are missing then relevant error messages are produced. It should also be noted that PowerShell Warnings do pop up for “breaking changes” and per my other scripts there are no special error control functions in my scripts.
The scripts works by producing the information into individual files as well as combining them all into one all with date/time stamps (it uses the name of the virtual network gateway / express route circuit). If the function is called standalone you just need to supply the Subscription name as a parameter. The script will then make sure that actual Subscription is the current select one.
- Select the specified subscription
- Setup folder locations for output files
- Search for Virtual Network Gateways/Express Routes and if found
- Check for output file folder and create if required
- Otherwise advise none found
- For each loops will run for any found gateways/circuits that are found.
The Virtual Network Gateway For each loop obtains the Learned Routes into Table format, if for some reason no output is produced the output file is deleted. It then obtain the BGP Peer Status in Format table and again if for some reason it’s empty the output file is deleted.
The Express Route Circuit For each loop Gets the Circuit config info to file and strips any presence of “Etag” fields of data. It then fetches all the ARP tables for all peerings and then all the Route tables for all peerings. It then creates a combined output file of all the content.
If you want you can use the “Comp-AzData” function which is the compare function script is contained at the bottom of another blog post at http://roity.com/tech/2020/06/27/gather-and-compare-configuration-info-in-azure/. To compare the Virtual Network Gateway routes then within the folder the output files are located you could execute “Comp-AzData -Pattern *-virtual-network-gateway-LR.txt” for instance or to compare the Express Route Circuits you could execute “Comp-AzData -Pattern *-er-circuit-name-Routes.txt”. You can optionally use the -DocDir parameter to specify the folder location of the output files. I haven’t as yet Integrated the file comparison function to automatically do the comparisons as part of the capture process
The scripts can take some minutes to run. I’ve combined this function into the set of scripts I published earlier linked above by adding “Get-AzNetGates $aztenantname” to the Az-GatherInfo.ps1 file directly after the “foreach ($azg in $azget)” loop and adding the entire function below into the “Az-GatherInfoFuncs.ps1” file.
Az-GatherInfoFuncs script located at https://github.com/roity57/Azure-Gather-and-Compare-Info/blob/master/Modules/Az-GatherInfoFuncs.ps1