Azure Management Data Bricks Client Library for Python

2.0.0 · active · verified Tue Apr 14

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

Install

Imports

Quickstart

This quickstart demonstrates how to authenticate using `DefaultAzureCredential` and list Azure Databricks workspaces within a subscription. Ensure `AZURE_SUBSCRIPTION_ID`, and potentially `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET` environment variables are set for successful authentication.

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})")

view raw JSON →