Registry / azure / azure-mgmt-dns

azure-mgmt-dns

JSON →
library9.0.0pypypi✓ verified 23d ago

The `azure-mgmt-dns` library provides a client for managing Azure DNS zones and record sets, including creating, updating, and deleting DNS resources within your Azure subscriptions. It is part of the Azure SDK for Python and is currently at version 9.0.0, with updates typically released as new API versions become available or significant features are added to the service.

pip install azure-mgmt-dns azure-identity
INSTALL
IMPORT
SIG · AZURE-MGMT-DNS
A
azure-mgmt-dns
azurepythonv9.0.0
Install
3.9s avg
Import
592ms
Disk
43MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v9.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 0.634s · 43.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.9s · import 0.550s · 44MB
43MB installed
● package 43MB
Code
Verified usage

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

DnsManagementClient
from azure.mgmt.dns import DnsManagementClient
DefaultAzureCredential
from azure.identity import DefaultAzureCredential

This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential`, create an instance of `DnsManagementClient`, and perform basic operations like creating and listing DNS zones. Remember to set your `AZURE_SUBSCRIPTION_ID` environment variable and ensure your credentials are configured (e.g., via Azure CLI login).

import os from azure.identity import DefaultAzureCredential from azure.mgmt.dns import DnsManagementClient # Set environment variables for authentication and subscription # AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID for Service Principal # Or configure AZURE_SUBSCRIPTION_ID subscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', 'YOUR_AZURE_SUBSCRIPTION_ID') resource_group_name = 'my-dns-rg' zone_name = 'example.com' # Authenticate using DefaultAzureCredential (looks for env vars, managed identity, etc.) credential = DefaultAzureCredential() dns_client = DnsManagementClient(credential, subscription_id) # Example: Create a DNS Zone print(f"Creating DNS Zone '{zone_name}' in resource group '{resource_group_name}'...") zone_parameters = { 'location': 'global' # DNS zones are 'global' for location } # Use begin_create_or_update and then .result() for long-running operations # In version 9.x, api_version is often required as a kwarg for begin_ operations zone_creation_poller = dns_client.zones.begin_create_or_update( resource_group_name, zone_name, zone_parameters, api_version='2018-05-01' ) zone = zone_creation_poller.result() print(f"Created Zone ID: {zone.id}") # Example: List DNS Zones in a resource group print(f"Listing DNS zones in resource group '{resource_group_name}':") for dns_zone in dns_client.zones.list_by_resource_group(resource_group_name): print(f"- {dns_zone.name}") # Example: Delete a DNS Zone (uncomment to run) # print(f"Deleting DNS Zone '{zone_name}'...") # dns_client.zones.begin_delete(resource_group_name, zone_name, api_version='2018-05-01').result() # print("Zone deleted.")
Debug
Known issues
breakingVersion 9.0.0 introduced significant breaking changes, primarily impacting API models and operation signatures. Specifically, the `DnsManagementClient.dns_resource_reference` operation was removed, and model types for parameters like `dns_resource_reference_request` and `zones_input` changed from `_models.Type` to the direct `Type` reference (e.g., `DnsResourceReferenceRequest`).
fix
Review the official release notes for `azure-mgmt-dns` version 9.0.0. Update your code to use the new model types and remove calls to the deprecated `dns_resource_reference` operation. Ensure your `import` statements for models are updated if you were relying on internal `_models`.
affects: >=9.0.0
breakingThe signatures for long-running operations such as `dns_client.zones.begin_create_or_update` and `dns_client.zones.begin_delete` have changed in version 9.x. The `api_version` parameter, which specifies the target Azure DNS API version, is now often required as a keyword argument rather than a positional argument.
fix
When calling `begin_` methods, explicitly pass `api_version` as a keyword argument: `dns_client.zones.begin_create_or_update(..., api_version='2018-05-01')`. Consult the API reference or samples for the correct `api_version` for your desired functionality.
affects: >=9.0.0
gotchaMany resource management operations in Azure SDKs are long-running and return an `LROPoller` object (e.g., `begin_create_or_update`). You must call `.result()` on the poller to wait for the operation to complete and retrieve the final resource object. In asynchronous contexts, you would `await poller`.
fix
Always append `.result()` to the call of a `begin_` method if you need the result immediately: `zone = dns_client.zones.begin_create_or_update(...).result()`. For async, use `zone = await dns_client.zones.begin_create_or_update(...)` if the client is async.
affects: All
gotchaWhen working with DNS record sets, the `record_type` (e.g., 'A', 'AAAA', 'CNAME') is crucial. The properties for each record type (e.g., `a_records`, `aaaa_records`) are mutually exclusive within a record set definition. Attempting to define properties for multiple record types in one call will result in an error or unexpected behavior.
fix
Ensure that when creating or updating a `RecordSet`, you only populate the properties relevant to the `record_type` you intend to manage. For example, for an 'A' record, only fill `a_records`.
affects: All
Upgrade
Version history
9.0.0latest on PyPI · released Jul 14, 2025
Audit
Dependencies
azure-corerequiredCore Azure SDK functionalities.
azure-mgmt-corerequiredCommon functionalities for Azure management plane clients.
azure-identityoptionalRecommended package for authenticating with Azure services.
Agent activity
42 hits · last 30 days
node
36
OpenAI (training)
1
Resources