This library eases working with known Azure IP networks in dotnet. AzureCloudServiceTag
provides the IP ranges for the entire
cloud and is also broken out by region within that cloud. You cannot create your own service tag nor can you specify which IP addresses are included within a tag. Microsoft manages the address prefixes encompassed by the service tag, and automatically updates the service tag and their addresses as they change.
Service tags are stored in a JSON file which contains the IP address ranges for Public Azure as a whole, each Azure region within Public, and ranges for several Azure services such as EventHub
, KeyVault
, Storage, SQL, and TrafficManager
in Public. The JSON file is downloaded from Microsoft's Website every so often from:
- https://www.microsoft.com/en-us/download/details.aspx?id=56519
- https://www.microsoft.com/en-us/download/details.aspx?id=57062
- https://www.microsoft.com/en-us/download/details.aspx?id=57063
- https://www.microsoft.com/en-us/download/details.aspx?id=57064
The library offers capabilities such as:
- Listing IP addresses or IP networks used by the whole of Azure or filtered to a single service tag.
- Checking if a given IP address or IP network belongs to Azure
The current version of the files can be found at files.json
You can also download the files from the remote URL once per application run using AzureIPsProvider.Remote.xxxx
methods
Using the .NET Core command-line interface (CLI) tools:
dotnet add package AzureIPNetworks
Using the NuGet Command Line Interface (CLI):
nuget install AzureIPNetworks
Using the Package Manager Console:
Install-Package AzureIPNetworks
From within Visual Studio:
- Open the Solution Explorer.
- Right-click on a project within your solution.
- Click on Manage NuGet Packages...
- Click on the Browse tab and search for "AzureIPNetworks".
- Click on the
AzureIPNetworks
package, select the appropriate version in the right-tab and click Install.
var networks = await AzureIPsProvider.Local.GetNetworksAsync(AzureCloud.Public);
foreach (var net in networks)
{
Console.WriteLine($"{net} ({range.FirstUsable} to {net.LastUsable})");
}
var ip = "30.0.0.20";
var used = await AzureIPsProvider.Local.IsAzureIpAsync(IPAddress.Parse(ip));
Console.WriteLine($"{ip} is {(used ? "" : "not")} used by any Azure service");
var networks = await AzureIPsProvider.Remote.GetNetworksAsync(AzureCloud.Public);
foreach (var net in networks)
{
Console.WriteLine($"{net} ({range.FirstUsable} to {net.LastUsable})");
}
var ip = "30.0.0.20";
var used = await AzureIPsProvider.Remote.IsAzureIpAsync(IPAddress.Parse(ip));
Console.WriteLine($"{ip} is {(used ? "" : "not")} used by any Azure service");
Please leave all comments, bugs, requests, and issues on the Issues page. We'll respond to your request ASAP!
The Library is licensed under the MIT license. Refer to the LICENSE file for more information.