Azure PowerShell for documenting VNETs

During a recent conversation I had with one of my customers I was asked if there was a way to export VNet settings from their Azure US Government subscription.  Of course PowerShell provides us the answer, however, it is not a simple single command.  

There is one command which allows you to export out all subscription VNETs along with their subnets and gateway information to an XML file.  There is another set of commands that enables you to query and navigate XML data in PowerShell.  Finally there is a command for getting network security group (NSG) information that is assigned to a subnet.

By combining all of these commands together into a structured script you can get a very good picture of your VNET configurations across your subscription.   I have built a sample script which you can download from here.

The script is for demonstration purposes only and comes with no support.  Do not utilize the script for production purposes without fully reviewing and understanding the code.   The script only looks at NSGs which are associated to subnets.  Currently Azure US Government only supports the ASM deployment model.  This script was designed to only work with that model and therefore may not be useful to people running workloads in Azure commercial under ARM.

Leave a Reply