{"id":1807,"library":"azure-mgmt-hdinsight","title":"Azure HDInsight Management Client Library","description":"The Microsoft Azure HDInsight Management Client Library for Python provides tools to manage Azure HDInsight clusters, including creation, deletion, scaling, and configuration. It is part of the Azure SDK for Python, currently at version 9.0.0, and typically receives updates aligning with Azure REST API changes and general SDK improvements.","status":"active","version":"9.0.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python","tags":["azure","cloud","hdinsight","management","bigdata"],"install":[{"cmd":"pip install azure-mgmt-hdinsight azure-identity","lang":"bash","label":"Install with identity"}],"dependencies":[{"reason":"Recommended for Azure Active Directory authentication.","package":"azure-identity","optional":false},{"reason":"Common Azure utilities, often a transitive dependency.","package":"azure-common","optional":false},{"reason":"Core Azure client runtime for track 1 SDKs.","package":"msrestazure","optional":false}],"imports":[{"symbol":"HDInsightManagementClient","correct":"from azure.mgmt.hdinsight import HDInsightManagementClient"},{"note":"DefaultAzureCredential from azure-identity is the modern, recommended authentication method for Azure SDKs.","wrong":"from azure.common.credentials import ServicePrincipalCredentials","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"},{"note":"It's best practice to import specific models directly for clarity and to avoid namespace pollution.","wrong":"from azure.mgmt.hdinsight.models import *","symbol":"models","correct":"from azure.mgmt.hdinsight.models import Cluster"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.hdinsight import HDInsightManagementClient\n\n# Set your Azure Subscription ID as an environment variable\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"<your-subscription-id>\")\nif subscription_id == \"<your-subscription-id>\":\n    print(\"Please set the AZURE_SUBSCRIPTION_ID environment variable or replace the placeholder.\")\n    exit(1)\n\n# Authenticate using DefaultAzureCredential, which tries multiple credential types\n# (environment variables, managed identity, VS Code, Azure CLI, etc.)\ncredential = DefaultAzureCredential()\n\n# Create the HDInsight Management Client\nclient = HDInsightManagementClient(credential, subscription_id)\n\nprint(f\"Listing all HDInsight clusters in subscription: {subscription_id}\")\n\ntry:\n    # List all clusters in the subscription\n    clusters = client.clusters.list()\n    found_clusters = False\n    for cluster in clusters:\n        found_clusters = True\n        print(f\"- Cluster Name: {cluster.name}, Location: {cluster.location}, State: {cluster.properties.cluster_state}\")\n    if not found_clusters:\n        print(\"No HDInsight clusters found in this subscription.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Make sure your AZURE_SUBSCRIPTION_ID is correct and you have appropriate permissions.\")\n\nprint(\"\\nListing available locations (capabilities) for HDInsight:\")\n# Note: list_capabilities often requires a specific location as input for context\n# We'll use 'eastus' as an example.\n# This might list an empty set if the subscription has no capabilities in 'eastus' or permission issues.\nlocations = client.locations.list_capabilities(\"eastus\")\nfound_locations = False\nfor location in locations:\n    found_locations = True\n    print(f\"- Location: {location.location}, VM Families: {len(location.regions_with_ FVM_families)}, Max Clusters: {location.max_cluster_count}\")\n    if found_locations: # Print only the first one for brevity\n        break\nif not found_locations:\n    print(\"No capabilities listed for 'eastus' or an error occurred.\")","lang":"python","description":"This quickstart demonstrates how to authenticate with Azure, initialize the `HDInsightManagementClient`, and then list all HDInsight clusters within your subscription, as well as fetch capabilities for a specific location. It uses `DefaultAzureCredential` for flexible authentication."},"warnings":[{"fix":"Consult the `azure-sdk-for-python` changelog and migration guides on GitHub or docs.microsoft.com for specific changes and updated code examples.","message":"Major version releases (e.g., 9.0.0) typically introduce breaking changes in API models, client constructors, or method signatures. Always review the migration guide in the official Azure SDK documentation when upgrading between major versions.","severity":"breaking","affected_versions":"9.0.0+"},{"fix":"After invoking an LRO method (e.g., `client.clusters.begin_create(...)`), store the returned poller object and then call `poller.result()` to ensure the operation finishes before proceeding.","message":"Many Azure management operations, such as creating or deleting clusters, are long-running operations (LROs). The SDK returns a poller object (e.g., `LROPoller`). You must call `.result()` on this poller to wait for the operation to complete and get its final outcome.","severity":"gotcha","affected_versions":"All"},{"fix":"Migrate your authentication logic to use `DefaultAzureCredential` from the `azure-identity` library. This allows for seamless authentication across development and production environments.","message":"Older authentication methods like directly using `ServicePrincipalCredentials` or `TokenCredentials` are being deprecated. The `azure-identity` library with `DefaultAzureCredential` is the recommended and most flexible approach for authentication across Azure SDKs.","severity":"deprecated","affected_versions":"<9.0.0 (and older versions of `msrestazure`)"},{"fix":"Verify that the `subscription_id` used for client initialization is correct and that the authenticated principal has 'Contributor' or equivalent roles on the target subscription/resource group. For resource-group specific operations, ensure the resource group exists and is correctly named.","message":"Azure HDInsight management operations are tied to a specific Azure subscription and often a resource group. Ensure you provide the correct `subscription_id` and `resource_group_name` to the client and methods, respectively. Incorrect context will lead to 'ResourceNotFound' or 'PermissionDenied' errors.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}