If you have spent much time working with Microsoft Azure, Amazon AWS or any public cloud provider, you have probably started to wonder about how many public IPv4 addresses they have. Whilst we know there is a limit to the number of addresses, and that we have reached these limits, it still seems like there are quite a few to go around.
I recently had the need to get a listing of all the Azure subnets, and whilst I did this, I thought it would be good to make a reusable PowerShell module to assist.
Microsoft makes this process pretty easy, providing an XML file under the Microsoft Download Center title: Microsoft Azure Datacenter IP Ranges. There are a few things to note about this file:
- It contains all compute (including SQL),
- It is updated on Wednesday (Pacific Time), but changes are effective from the following Monday (Pacific Time), and,
- The file will contain only production Azure DCs, for instance, at the time of writing the German and Canadian DCs are not contained in the file.
I have developed a PowerShell module that simplifies working with this file by developing CMDLets that:
- Allowing for automated downloads of the file, and,
- Allow for specific DCs to be extracted
Get-MicrosoftAzureDatacenterIPRangeFile provides us with a method to simply and easily access the XML document. If called without parameters, we will get the XML document returned, however we can opt to save the file to disk for future processing.
Then we have Get-MicrosoftAzureDatacenterIPRange. With this CMDLet, we can get a list of objects containing the subnets (in CIDR format) for a specific DC or for all of the DCs. You can specify the path to a previously downloaded file, or it can download the file for us (and keep it in memory).
The module can be found on:
I have tested this module against PowerShell 5, however there should be no issue with earlier versions (I recommend PowerShell 3 or higher). If you encounter any issues, please raise an issue on the GitHub page.
Just in case you were wondering, Azure has approximately 1700 subnets, or around 5.8 million IPv4 addresses!