{"id":1358,"library":"azure-mgmt-cdn","title":"Azure CDN Management Client Library","description":"The Azure CDN Management Client Library for Python provides programmatic access to manage Azure Content Delivery Network (CDN) resources. It allows users to create, configure, update, and delete CDN profiles, endpoints, and custom domains. Part of the broader Azure SDK for Python, it follows the SDK's consistent design principles and release cadence, typically receiving updates as new Azure API versions are released or significant changes occur in the underlying service, often with minor version bumps and major version updates for breaking changes.","status":"active","version":"13.1.1","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cdn/azure-mgmt-cdn","tags":["azure","cloud","cdn","management","sdk","microsoft"],"install":[{"cmd":"pip install azure-mgmt-cdn","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for authentication with Azure services using modern credential flows.","package":"azure-identity","optional":false},{"reason":"Provides shared primitives, exceptions, and operations for Azure SDK client libraries.","package":"azure-core","optional":false}],"imports":[{"symbol":"CdnManagementClient","correct":"from azure.mgmt.cdn import CdnManagementClient"},{"note":"Old authentication methods (e.g., from `azure-common` or `msrestazure`) are deprecated in favor of `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.cdn import CdnManagementClient\n\n# --- Configuration ---\n# Ensure AZURE_SUBSCRIPTION_ID is set in your environment variables.\n# You can also set AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET for service principal auth.\n\nAZURE_SUBSCRIPTION_ID = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"\")\n\nif not AZURE_SUBSCRIPTION_ID:\n    print(\"Please set the AZURE_SUBSCRIPTION_ID environment variable.\")\n    exit(1)\n\nprint(f\"Using Subscription ID: {AZURE_SUBSCRIPTION_ID}\")\n\n# Authenticate with Azure using DefaultAzureCredential\n# This credential chain attempts to authenticate via various methods:\n# Environment variables, Managed Identity, Visual Studio Code, Azure CLI, Azure PowerShell.\ncredential = DefaultAzureCredential()\n\n# Create a CDN management client\n# All CDN operations are performed through this client object.\nclient = CdnManagementClient(credential, AZURE_SUBSCRIPTION_ID)\n\nprint(\"\\nListing CDN Profiles in the subscription...\")\n# List all CDN profiles. This returns an iterator (ItemPaged).\n# Iterating directly fetches pages as needed.\ncdn_profiles = client.profiles.list()\n\nprofile_count = 0\nfor profile in cdn_profiles:\n    profile_count += 1\n    print(f\"  - Profile Name: {profile.name}, Location: {profile.location}, Sku: {profile.sku.name}\")\n\nif profile_count == 0:\n    print(\"  No CDN profiles found in this subscription.\")\nelse:\n    print(f\"Found {profile_count} CDN profile(s).\")\n\n# Example of a long-running operation (creation of a CDN profile)\n# This would typically involve a begin_ method and a poller.\n# resource_group_name = \"myResourceGroup\"\n# profile_name = \"myUniqueCdnProfile\"\n# profile_parameters = {\n#     \"location\": \"westus\",\n#     \"sku\": {\"name\": \"Standard_Microsoft\"}\n# }\n# print(f\"\\nStarting creation of CDN Profile '{profile_name}'...\")\n# poller = client.profiles.begin_create(resource_group_name, profile_name, profile_parameters)\n# profile = poller.result() # Wait for the operation to complete\n# print(f\"CDN Profile '{profile.name}' created successfully.\")","lang":"python","description":"This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and list existing CDN profiles in your subscription. Ensure the `AZURE_SUBSCRIPTION_ID` environment variable is set. It highlights the typical pattern for creating the client and iterating over paginated results."},"warnings":[{"fix":"Update authentication code to use `azure.identity.DefaultAzureCredential` or other `azure-identity` credentials. Review the official changelog for specific API changes to resource models and operations.","message":"Major version 13.0.0 introduced significant breaking changes, primarily standardizing on `azure-identity` for authentication and `azure-core` for common client primitives. If upgrading from versions prior to 13.0.0, expect changes to authentication mechanisms and potentially to resource model classes and method signatures.","severity":"breaking","affected_versions":"<13.0.0"},{"fix":"Always call `.result()` on the `begin_` method's return value for long-running operations: `poller = client.profiles.begin_create(...); created_profile = poller.result()`.","message":"Operations that create, update, or delete resources (e.g., `profiles.begin_create`) are often long-running operations and return a 'poller' object (e.g., `LROPoller`). You must call `.result()` on the poller to wait for the operation to complete and retrieve the final resource object or status.","severity":"gotcha","affected_versions":">=13.0.0"},{"fix":"Iterate directly over the returned object (e.g., `for profile in client.profiles.list():`) or convert it explicitly to a list if all results are needed at once (e.g., `list(client.profiles.list())`).","message":"Listing operations (e.g., `client.profiles.list()`, `client.endpoints.list_by_profile()`) return an iterable object (e.g., `ItemPaged`), not a direct list. This object automatically handles pagination internally. Attempting to index directly or treat it as a static list without iterating might lead to unexpected behavior or incomplete data.","severity":"gotcha","affected_versions":">=13.0.0"},{"fix":"For troubleshooting, enable logging for `azure.identity`. For explicit control, use specific credential classes like `EnvironmentCredential`, `ManagedIdentityCredential`, or `ServicePrincipalCredential` from `azure.identity`.","message":"`DefaultAzureCredential` attempts multiple authentication methods. While convenient, it can sometimes be unclear which method is being used or why authentication is failing. For production environments or specific scenarios (e.g., CI/CD, Managed Identity), it's often more robust to explicitly use a specific credential type.","severity":"gotcha","affected_versions":">=13.0.0"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}