Azure Management Data Bricks Client Library for Python
The Microsoft Azure Data Bricks Management Client Library for Python allows end users to operate on Azure Databricks Workspace and Access Connector resources. It is currently at version 2.0.0 and requires Python 3.7+. As part of the broader Azure SDK for Python, it follows a regular release cadence with updates and new features, with the last major release (2.0.0) on June 29, 2023.
Warnings
- breaking The credential system was completely revamped in v2.x. Classes like `azure.common.credentials` or `msrestazure.azure_active_directory` are no longer supported. You must migrate to `azure-identity` classes (e.g., `DefaultAzureCredential`). The client constructor parameter `credentials` was renamed to `credential`.
- breaking Operations that previously returned `msrest.polling.LROPoller` for long-running operations (LROs) now return `azure.core.polling.LROPoller` and are typically prefixed with `begin_` (e.g., `create_or_update` becomes `begin_create_or_update`).
- breaking The exception hierarchy has been simplified. Most exceptions are now `azure.core.exceptions.HttpResponseError`. The `CloudError` exception has been removed.
- gotcha This library (`azure-mgmt-databricks`) is for *managing* Azure Databricks workspaces and resources (create, update, delete). It is distinct from the `Databricks SDK for Python` (pypi: `databricks-sdk`), which is used for interacting with Databricks *within* a Databricks environment (e.g., notebooks, jobs, clusters, data plane operations) or through the Databricks REST API. Users often confuse these two, leading to incorrect package usage for their intended task.
- gotcha Python 2.7 support for Azure SDK for Python packages ended on January 1, 2022. This `azure-mgmt-databricks` package specifically requires Python 3.7 or newer.
Install
-
pip install azure-mgmt-databricks azure-identity
Imports
- AzureDatabricksManagementClient
from azure.mgmt.databricks import AzureDatabricksManagementClient
- DefaultAzureCredential
from azure.identity import DefaultAzureCredential
Quickstart
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.databricks import AzureDatabricksManagementClient
# Set these environment variables or replace with actual values
# AZURE_SUBSCRIPTION_ID, AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "")
if not subscription_id:
raise ValueError("AZURE_SUBSCRIPTION_ID environment variable not set.")
# Authenticate using DefaultAzureCredential
# This will try to authenticate using various methods (env vars, managed identity, Azure CLI, etc.)
credential = DefaultAzureCredential()
# Create the Databricks Management Client
client = AzureDatabricksManagementClient(credential=credential, subscription_id=subscription_id)
# Example: List all Databricks workspaces in the subscription
print("Listing Databricks workspaces:")
for workspace in client.workspaces.list_by_subscription():
print(f" - {workspace.name} (Resource Group: {workspace.id.split('/')[4]}) (Location: {workspace.location})")