Skip to main content

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:

  • name
  • properties.region
  • properties.systemService
  • properties.platform
  • properties.addressPrefixes

The top-level payload includes:

  • changeNumber
  • cloud

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 strings
  • change_number: source change number from Azure
  • cloud: source cloud identifier (for example Public)
  • source_url: final JSON URL used
  • selected_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"

Metadata

Release files for azure-json-ips 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for azure-json-ips 0.1.0
File Size Uploaded
azure_json_ips-0.1.0.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for azure-json-ips 0.1.0
File Interpreter ABI Platform
azure_json_ips-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.7 kB

Release files / azure_json_ips-0.1.0.tar.gz

Download URL azure_json_ips-0.1.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0ae640d16611e2f112fef194f583bed943b86bc2379fd4e2b81440d860411d79
BLAKE2b-256 checksum
How to use checksums
13e043c4fcc2c3419ee814015caa1b6329ea824eafcb90f3310220660167e789
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / azure_json_ips-0.1.0-py3-none-any.whl

Download URL azure_json_ips-0.1.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8ff0afaa860b119e75d351c995365b2a0317237e7b30c752d251935325099a7
BLAKE2b-256 checksum
How to use checksums
43cf110722bac4d9b596bc01e0e0b29155418cbe5b0d2e9aeefb6ed954546612
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page