Registry / azure / azure-mgmt-network

azure-mgmt-network

JSON →
library32.0.0pypypi✓ verified 26d ago

The Microsoft Azure Network Management Client Library for Python provides programmatic access to manage network resources within Azure subscriptions, including virtual networks, public IPs, network security groups, and more. It is part of the broader Azure SDK for Python and is currently at version 30.2.0, with regular updates aligning with Azure service API changes.

pip install azure-mgmt-network azure-identity
INSTALL
IMPORT
SIG · AZURE-MGMT-NETWORK
A
azure-mgmt-network
azurepythonv32.0.0
Install
5.4s avg
Import
1619ms
Disk
67MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v32.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.696s · 65.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.4s · import 1.542s · 66MB
67MB installed
● package 67MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NetworkManagementClient
from azure.mgmt.network import NetworkManagementClient
DefaultAzureCredential
from azure.identity import DefaultAzureCredential

This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and list all public IP addresses across your subscription using the `NetworkManagementClient`. Ensure you have `AZURE_SUBSCRIPTION_ID` and other necessary authentication environment variables set for `DefaultAzureCredential` to work correctly (e.g., `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET` for service principal, or log in via Azure CLI).

import os from azure.identity import DefaultAzureCredential from azure.mgmt.network import NetworkManagementClient # Retrieve subscription ID from environment variable or replace with your ID # You must set AZURE_SUBSCRIPTION_ID, AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET # (or use other authentication methods supported by DefaultAzureCredential) SUBSCRIPTION_ID = os.environ.get("AZURE_SUBSCRIPTION_ID", "YOUR_SUBSCRIPTION_ID") if SUBSCRIPTION_ID == "YOUR_SUBSCRIPTION_ID": print("Warning: Please set the AZURE_SUBSCRIPTION_ID environment variable.") print("Or replace 'YOUR_SUBSCRIPTION_ID' in the code with your actual ID.") exit(1) # Authenticate using DefaultAzureCredential (recommended for most scenarios) try: credential = DefaultAzureCredential() # For local development, ensure Azure CLI is logged in, or relevant env vars are set credential.get_token("https://management.azure.com/.default") # Test token acquisition except Exception as e: print(f"Authentication failed: {e}") print("Please ensure you are logged into Azure CLI, have appropriate environment variables set,") print("or use a different credential type.") exit(1) # Create a NetworkManagementClient instance network_client = NetworkManagementClient(credential, SUBSCRIPTION_ID) # Example: List all Public IP Addresses in the subscription print("Listing Public IP Addresses...") public_ips = network_client.public_ip_addresses.list_all() for ip in public_ips: print(f" - Name: {ip.name}, IP Address: {ip.ip_address or 'N/A'}, Resource Group: {ip.id.split('/')[4]}") print("Public IP Address listing complete.")
Debug
Known issues
breakingAuthentication method changes: The Azure SDK for Python (v20.0.0 and later) deprecated legacy credential classes like `ServicePrincipalCredentials` in `azure.common.credentials`. Modern authentication exclusively uses classes from `azure.identity` (e.g., `DefaultAzureCredential`).
fix
Migrate your authentication code to use `azure.identity.DefaultAzureCredential` or other specific `azure.identity` credential types. Ensure `azure-identity` is installed via `pip install azure-identity`.
affects: Prior to v20.0.0 (legacy) to v20.0.0 and later.
gotchaLong-Running Operations (LROs) now return a poller object. Operations like `create_or_update`, `delete`, and `begin_xyz` (prefixed) for resource provisioning or modification are asynchronous. They return an `LROPoller` object, not the final resource or `None` directly.
fix
Always call `.result()` on the `LROPoller` object to wait for the operation's completion and retrieve its final outcome (e.g., the created resource). Example: `virtual_network = network_client.virtual_networks.begin_create_or_update(...).result()`.
affects: All versions, but the expectation of immediate return changed significantly around v20.0.0.
breakingSignificant API changes and refactoring occurred around v20.0.0. This includes changes to client method signatures, model classes, and how collection methods (`list`) are handled. Direct access to `.value` on list results is no longer necessary; iterators are returned.
fix
Refer to the official Azure SDK for Python migration guides for `azure-mgmt-network` to update method calls and model property access. List methods now return auto-paginated iterators, so direct iteration over the result is sufficient.
affects: Prior to v20.0.0 to v20.0.0 and later.
gotchaAzure SDK clients often require an Azure Subscription ID for proper operation. This ID must be provided either through the `AZURE_SUBSCRIPTION_ID` environment variable, or passed explicitly as an argument during client initialization or specific method calls.
fix
Set the `AZURE_SUBSCRIPTION_ID` environment variable to your Azure subscription ID, or provide the subscription ID as an argument when instantiating the client or calling relevant methods. For example: `os.environ['AZURE_SUBSCRIPTION_ID'] = 'YOUR_SUBSCRIPTION_ID'`.
affects: All versions, especially for resource management clients.
gotchaMissing AZURE_SUBSCRIPTION_ID: Many Azure SDK for Python operations and samples require the `AZURE_SUBSCRIPTION_ID` to be set as an environment variable or passed directly to client constructors/methods. Failure to provide it will result in warnings or errors during client initialization or resource operations.
fix
Ensure the `AZURE_SUBSCRIPTION_ID` environment variable is set (e.g., `export AZURE_SUBSCRIPTION_ID='YOUR_SUBSCRIPTION_ID'`) before running SDK code, or replace placeholder IDs in your code with your actual subscription ID.
affects: All versions
Upgrade
Version history
32.0.0latest on PyPI · released Aug 17, 2026
Audit
Dependencies
azure-mgmt-corerequiredCore management client functionality
azure-commonrequiredCommon Azure utilities and types
azure-identityoptionalRecommended for modern Azure authentication (e.g., DefaultAzureCredential)
Agent activity
31 hits · last 30 days
node
26
OpenAI (training)
1
Resources
azure-mgmt-network — pip install azure-mgmt-network · libregistry