{"id":5750,"library":"azure-mgmt-kusto","title":"Microsoft Azure Kusto Management Client Library for Python","description":"The `azure-mgmt-kusto` library is the Microsoft Azure Kusto Management Client Library for Python, used to programmatically manage Azure Kusto (Azure Data Explorer) clusters and databases. It enables operations such as creating, updating, and deleting Kusto clusters and their associated databases. The library follows the modern Azure SDK guidelines and requires Python 3.8 or later. The current version is 3.4.0, released on 2024-01-24.","status":"active","version":"3.4.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python","tags":["azure","kusto","data explorer","management","cloud","sdk","arm"],"install":[{"cmd":"pip install azure-mgmt-kusto azure-identity","lang":"bash","label":"Install core and authentication libraries"}],"dependencies":[{"reason":"Required for Azure Active Directory token authentication.","package":"azure-identity","optional":false},{"reason":"Requires Python version 3.8 or greater.","package":"Python","optional":false}],"imports":[{"note":"The direct import path for KustoManagementClient changed in breaking versions (e.g., v3.0.0) for consistency with new SDK guidelines.","wrong":"from azure.mgmt.kusto.kusto_management_client import KustoManagementClient","symbol":"KustoManagementClient","correct":"from azure.mgmt.kusto import KustoManagementClient"},{"note":"Model imports should use 'from azure.mgmt.kusto.models import ...' rather than direct attribute access on the models module.","wrong":"import azure.mgmt.kusto.models.cluster","symbol":"models","correct":"from azure.mgmt.kusto.models import Cluster"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.kusto import KustoManagementClient\n\n# Set environment variables for authentication and subscription ID\n# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET (for service principal)\n# AZURE_SUBSCRIPTION_ID\n\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"YOUR_SUBSCRIPTION_ID\")\nif not subscription_id or subscription_id == \"YOUR_SUBSCRIPTION_ID\":\n    raise ValueError(\"AZURE_SUBSCRIPTION_ID environment variable not set or is a placeholder.\")\n\n# Authenticate using DefaultAzureCredential. This credential will attempt\n# to use various authentication methods, such as environment variables,\n# managed identity, or Azure CLI, in a prioritized order.\ncredential = DefaultAzureCredential()\n\n# Create Kusto Management Client\nclient = KustoManagementClient(credential=credential, subscription_id=subscription_id)\n\n# Example: List Kusto Clusters in a resource group\n# Replace 'YOUR_RESOURCE_GROUP' with an actual resource group name where Kusto clusters exist.\nresource_group_name = os.environ.get(\"KUSTO_RESOURCE_GROUP_NAME\", \"YOUR_RESOURCE_GROUP\")\n\nif not resource_group_name or resource_group_name == \"YOUR_RESOURCE_GROUP\":\n    print(\"Warning: KUSTO_RESOURCE_GROUP_NAME environment variable not set or is a placeholder. Skipping cluster listing example.\")\nelse:\n    print(f\"Listing Kusto clusters in resource group: {resource_group_name}\")\n    try:\n        for cluster in client.clusters.list_by_resource_group(resource_group_name):\n            print(f\"- {cluster.name} (Location: {cluster.location}, SKU: {cluster.sku.name})\")\n    except Exception as e:\n        print(f\"Error listing clusters: {e}. Ensure the resource group exists and you have permissions.\")\n","lang":"python","description":"This quickstart demonstrates how to authenticate with `DefaultAzureCredential` and instantiate the `KustoManagementClient`. It then shows how to list Kusto clusters within a specified resource group. Ensure that the required environment variables (`AZURE_SUBSCRIPTION_ID`, and optionally `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`, `KUSTO_RESOURCE_GROUP_NAME`) are set for successful execution."},"warnings":[{"fix":"Install `azure-identity` (`pip install azure-identity`) and update your authentication code to use `DefaultAzureCredential` or other `azure-identity` classes. Change `credentials=` to `credential=` when instantiating the client.","message":"The credential system was completely revamped in versions around 1.0.0b1/3.0.0. Old `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported. Use classes from `azure-identity` (e.g., `DefaultAzureCredential`). The client constructor parameter `credentials` was renamed to `credential`.","severity":"breaking","affected_versions":">=1.0.0b1, >=3.0.0"},{"fix":"Import `KustoManagementClient` directly from the top-level package: `from azure.mgmt.kusto import KustoManagementClient`. Import model classes from the `azure.mgmt.kusto.models` submodule: `from azure.mgmt.kusto.models import Cluster`.","message":"Import paths for the client and model classes changed significantly with versions around 1.0.0b1/3.0.0. `KustoManagementClient` can no longer be imported from `azure.mgmt.kusto.kusto_management_client`. Similarly, models cannot be imported via direct attribute access like `azure.mgmt.kusto.models.my_class`.","severity":"breaking","affected_versions":">=1.0.0b1, >=3.0.0"},{"fix":"Adjust code to use the `begin_` prefix for long-running operations and handle `azure.core.exceptions.HttpResponseError` for general API errors.","message":"Operations that used to return a `msrest.polling.LROPoller` now return `azure.core.polling.LROPoller` and are typically prefixed with `begin_`. The exception hierarchy has also been simplified, with most exceptions now being `azure.core.exceptions.HttpResponseError` (the `CloudError` class has been removed).","severity":"breaking","affected_versions":">=1.0.0b1, >=3.0.0"},{"fix":"Ensure your development and deployment environments use Python 3.8 or a later version.","message":"Support for Python 2.7 for Azure SDK Python packages ended on January 1, 2022. This library, `azure-mgmt-kusto`, requires Python 3.8 or newer.","severity":"gotcha","affected_versions":"<3.8"},{"fix":"Set the required environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`, and `AZURE_SUBSCRIPTION_ID`. Refer to the `azure-identity` documentation for alternative authentication flows (e.g., Azure CLI, Managed Identity).","message":"For `DefaultAzureCredential` to authenticate correctly outside of Azure-hosted environments (like local development without Managed Identity), specific environment variables must be configured: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET` for service principal authentication, and `AZURE_SUBSCRIPTION_ID` for the client to target a subscription.","severity":"gotcha","affected_versions":"All versions using `azure-identity`"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}