{"id":1808,"library":"azure-mgmt-privatedns","title":"Azure Management Private DNS Client Library","description":"The Microsoft Azure DNS Private Zones Client Library for Python allows you to create, configure, and manage private DNS zones within your Azure virtual networks. It provides programmatic access to manage private DNS zones, virtual network links, and DNS record sets. The current version is 1.2.0, released on September 23, 2024, and it is part of the Azure SDK for Python, which follows a regular release cadence with frequent updates across its libraries.","status":"active","version":"1.2.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python","tags":["azure","management","dns","private","cloud","sdk"],"install":[{"cmd":"pip install azure-mgmt-privatedns azure-identity","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Required for Azure Active Directory token authentication.","package":"azure-identity","optional":false}],"imports":[{"symbol":"PrivateDnsManagementClient","correct":"from azure.mgmt.privatedns import PrivateDnsManagementClient"},{"note":"Old credential classes are deprecated and no longer supported; use azure-identity.","wrong":"from azure.common.credentials import ServicePrincipalCredentials","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.privatedns import PrivateDnsManagementClient\n\n# Set your Azure Subscription ID as an environment variable or replace with your ID\n# os.environ[\"AZURE_SUBSCRIPTION_ID\"] = \"<your-subscription-id>\"\n\n# Authenticate using DefaultAzureCredential. It will try various methods like environment variables,\n# managed identity, Azure CLI, etc. For development, ensure AZURE_CLIENT_ID, AZURE_TENANT_ID,\n# and AZURE_CLIENT_SECRET (or AZURE_CLI_AUTH_TOKEN for CLI login) are set.\ncredential = DefaultAzureCredential()\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"\")\n\nif not subscription_id:\n    raise ValueError(\"AZURE_SUBSCRIPTION_ID environment variable not set.\")\n\nclient = PrivateDnsManagementClient(credential=credential, subscription_id=subscription_id)\n\n# Example: List all private DNS zones in the subscription\nprint(\"Listing Private DNS Zones:\")\nfor zone in client.private_zones.list():\n    print(f\"  - Zone Name: {zone.name}, Resource Group: {zone.id.split('/')[4]}\")\n\n# In a real application, ensure proper error handling and resource management (e.g., closing the client if needed).\n# client.close() # if using an older client or specific scenarios, typically not needed for management clients.","lang":"python","description":"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."},"warnings":[{"fix":"Migrate authentication to use classes from the `azure-identity` library, such as `DefaultAzureCredential`.","message":"The credential system was completely revamped. Old `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported.","severity":"breaking","affected_versions":"Introduced in 1.0.0b1 (2021-02-09) and later versions."},{"fix":"Update LRO calls to use the `begin_` prefix and `azure.core.polling.LROPoller`. Refactor exception handling to catch `azure.core.exceptions.HttpResponseError`.","message":"Long-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`.","severity":"breaking","affected_versions":"Introduced in 1.0.0b1 (2021-02-09) and later versions."},{"fix":"Before deleting a Private DNS zone, ensure all associated virtual network links are removed, and be aware of the irreversible deletion of all records.","message":"Deleting 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Only 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.","message":"The `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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}