{"id":2405,"library":"azure-mgmt-dns","title":"Azure DNS Management Client Library","description":"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.","status":"active","version":"9.0.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/dns/azure-mgmt-dns","tags":["azure","cloud","dns","management","sdk"],"install":[{"cmd":"pip install azure-mgmt-dns azure-identity","lang":"bash","label":"Install core library and authentication"}],"dependencies":[{"reason":"Core Azure SDK functionalities.","package":"azure-core","optional":false},{"reason":"Common functionalities for Azure management plane clients.","package":"azure-mgmt-core","optional":false},{"reason":"Recommended package for authenticating with Azure services.","package":"azure-identity","optional":true}],"imports":[{"symbol":"DnsManagementClient","correct":"from azure.mgmt.dns import DnsManagementClient"},{"symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.dns import DnsManagementClient\n\n# Set environment variables for authentication and subscription\n# AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID for Service Principal\n# Or configure AZURE_SUBSCRIPTION_ID\n\nsubscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', 'YOUR_AZURE_SUBSCRIPTION_ID')\nresource_group_name = 'my-dns-rg'\nzone_name = 'example.com'\n\n# Authenticate using DefaultAzureCredential (looks for env vars, managed identity, etc.)\ncredential = DefaultAzureCredential()\n\ndns_client = DnsManagementClient(credential, subscription_id)\n\n# Example: Create a DNS Zone\nprint(f\"Creating DNS Zone '{zone_name}' in resource group '{resource_group_name}'...\")\nzone_parameters = {\n    'location': 'global' # DNS zones are 'global' for location\n}\n\n# Use begin_create_or_update and then .result() for long-running operations\n# In version 9.x, api_version is often required as a kwarg for begin_ operations\nzone_creation_poller = dns_client.zones.begin_create_or_update(\n    resource_group_name,\n    zone_name,\n    zone_parameters,\n    api_version='2018-05-01'\n)\nzone = zone_creation_poller.result()\nprint(f\"Created Zone ID: {zone.id}\")\n\n# Example: List DNS Zones in a resource group\nprint(f\"Listing DNS zones in resource group '{resource_group_name}':\")\nfor dns_zone in dns_client.zones.list_by_resource_group(resource_group_name):\n    print(f\"- {dns_zone.name}\")\n\n# Example: Delete a DNS Zone (uncomment to run)\n# print(f\"Deleting DNS Zone '{zone_name}'...\")\n# dns_client.zones.begin_delete(resource_group_name, zone_name, api_version='2018-05-01').result()\n# print(\"Zone deleted.\")\n","lang":"python","description":"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)."},"warnings":[{"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`.","message":"Version 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`).","severity":"breaking","affected_versions":">=9.0.0"},{"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.","message":"The 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.","severity":"breaking","affected_versions":">=9.0.0"},{"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.","message":"Many 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`.","severity":"gotcha","affected_versions":"All"},{"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`.","message":"When 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.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}