Install & Compatibility
Where this runs
tested against v2.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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.598s · 44MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.9s · import 0.538s · 44MB
43MB installed
● package 43MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
PrivateDnsManagementClient
✓ from azure.mgmt.privatedns import PrivateDnsManagementClient
DefaultAzureCredential
✓ from azure.identity import DefaultAzureCredential
✗ from azure.common.credentials import ServicePrincipalCredentials
Old credential classes are deprecated and no longer supported; use azure-identity.
This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and then list all Private DNS zones available in your subscription using `PrivateDnsManagementClient`. Ensure your `AZURE_SUBSCRIPTION_ID` environment variable is set for this example to run correctly, along with other necessary Azure Identity environment variables for authentication.
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.privatedns import PrivateDnsManagementClient
# Set your Azure Subscription ID as an environment variable or replace with your ID
# os.environ["AZURE_SUBSCRIPTION_ID"] = "<your-subscription-id>"
# Authenticate using DefaultAzureCredential. It will try various methods like environment variables,
# managed identity, Azure CLI, etc. For development, ensure AZURE_CLIENT_ID, AZURE_TENANT_ID,
# and AZURE_CLIENT_SECRET (or AZURE_CLI_AUTH_TOKEN for CLI login) are set.
credential = DefaultAzureCredential()
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "")
if not subscription_id:
raise ValueError("AZURE_SUBSCRIPTION_ID environment variable not set.")
client = PrivateDnsManagementClient(credential=credential, subscription_id=subscription_id)
# Example: List all private DNS zones in the subscription
print("Listing Private DNS Zones:")
for zone in client.private_zones.list():
print(f" - Zone Name: {zone.name}, Resource Group: {zone.id.split('/')[4]}")
# In a real application, ensure proper error handling and resource management (e.g., closing the client if needed).
# client.close() # if using an older client or specific scenarios, typically not needed for management clients.
Debug
Known issues
breakingThe credential system was completely revamped. Old `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported.fixMigrate authentication to use classes from the `azure-identity` library, such as `DefaultAzureCredential`.
affects: Introduced in 1.0.0b1 (2021-02-09) and later versions.
breakingLong-Running Operations (LRO) pollers and exception handling changed. Operations returning `msrest.polling.LROPoller` now return `azure.core.polling.LROPoller` and are prefixed with `begin_`. Most exceptions are now `azure.core.exceptions.HttpResponseError` instead of `CloudError`.fixUpdate LRO calls to use the `begin_` prefix and `azure.core.polling.LROPoller`. Refactor exception handling to catch `azure.core.exceptions.HttpResponseError`.
affects: Introduced in 1.0.0b1 (2021-02-09) and later versions.
gotchaDeleting a Private DNS zone also deletes all DNS records within it, and this operation cannot be undone. Furthermore, a Private DNS zone cannot be deleted unless all virtual network links to it are first removed.fixBefore deleting a Private DNS zone, ensure all associated virtual network links are removed, and be aware of the irreversible deletion of all records.
affects: All versions
gotchaThe `PrivateDnsManagementClient` constructor accepts an `api_version` parameter. While it has a default, explicitly overriding it with an unsupported or outdated value can lead to unexpected API behavior or errors.fixOnly override the `api_version` if you explicitly need to target a specific, compatible API version. Generally, rely on the SDK's default for the latest supported behavior.
affects: All versions
Upgrade
Version history
2.0.0latest on PyPI · released Jul 29, 2026
Audit
Dependencies
azure-identityrequiredRequired for Azure Active Directory token authentication.