Resolve Azure IP CIDR ranges from Microsoft's published service tags JSON
Project description
azure-json-ips
Python library that resolves Azure-published IP ranges from Microsoft's service tags JSON source.
It fetches and parses service tags data, extracts IPv4 and IPv6 CIDRs, and can optionally filter by region, system service, platform, or full tag name.
Why JSON?
Azure publishes service tag metadata in a machine-readable JSON payload. It
contains top-level metadata and a values list with network definitions.
Each service tag entry includes fields such as:
nameproperties.regionproperties.systemServiceproperties.platformproperties.addressPrefixes
The top-level payload includes:
changeNumbercloud
This package reads that source directly.
Install
From PyPI
pip install azure-json-ips
Local Development
From the project root:
pip install -e .
Library Usage
from azure_json_ips import AzureIPQuery, get_azure_ip_cidrs
result = get_azure_ip_cidrs()
query = AzureIPQuery.from_cidrs(result.cidrs)
print(result.change_number, result.cloud)
print(query.contains("20.36.0.0/14"))
print(query.collides("20.36.0.0-20.39.255.255"))
You can also filter the source data:
result = get_azure_ip_cidrs(
regions=("eastus",),
system_services=("Storage",),
)
result is a ResolutionResult with:
cidrs: sorted tuple of unique CIDR stringschange_number: source change number from Azurecloud: source cloud identifier (for examplePublic)source_url: final JSON URL usedselected_prefix_count: number of selected address prefixes before de-duplication
AzureIPQuery supports:
contains(value): full containment for IP, CIDR, or range string (start-end)collides(value): any overlap for IP, CIDR, or range string (start-end)- Specific methods:
contains_ip,contains_cidr,contains_range,collides_ip,collides_cidr,collides_range
Example Script
Run:
python examples/print_azure_ips.py
Flask JSON Server Example
Run:
python examples/flask_server.py
All endpoints return JSON.
Examples:
curl "http://127.0.0.1:5003/health"
curl "http://127.0.0.1:5003/metadata"
curl "http://127.0.0.1:5003/cidrs"
curl "http://127.0.0.1:5003/networks"
curl "http://127.0.0.1:5003/check?value=20.36.0.0/14"
curl "http://127.0.0.1:5003/check?value=20.36.0.0-20.39.255.255"
curl "http://127.0.0.1:5003/check/range?start=20.36.0.0&end=20.39.255.255"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file azure_json_ips-0.1.0.tar.gz.
File metadata
- Download URL: azure_json_ips-0.1.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ae640d16611e2f112fef194f583bed943b86bc2379fd4e2b81440d860411d79
|
|
| MD5 |
720b4db1f0cacc671af993e10013f5b2
|
|
| BLAKE2b-256 |
13e043c4fcc2c3419ee814015caa1b6329ea824eafcb90f3310220660167e789
|
File details
Details for the file azure_json_ips-0.1.0-py3-none-any.whl.
File metadata
- Download URL: azure_json_ips-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8ff0afaa860b119e75d351c995365b2a0317237e7b30c752d251935325099a7
|
|
| MD5 |
368f6f21809edf346782e36933ff08f0
|
|
| BLAKE2b-256 |
43cf110722bac4d9b596bc01e0e0b29155418cbe5b0d2e9aeefb6ed954546612
|