The framework now supports Databricks CLI authentication, making it easier to connect to your workspaces without managing tokens manually.
pip install databricks-clidatabricks configure --tokenYou'll be prompted for:
- Databricks Host: Your workspace URL (e.g.,
https://your-workspace.cloud.databricks.com) - Token: Your personal access token
That's it! The framework will automatically use your CLI configuration:
dbx_test run --remoteThe framework supports multiple authentication methods with the following priority:
Specify in config/test_config.yml:
workspace:
host: "https://your-workspace.cloud.databricks.com"
token: "dapi..."Note: Not recommended for production (tokens in files).
export DATABRICKS_HOST="https://your-workspace.cloud.databricks.com"
export DATABRICKS_TOKEN="dapi..."Leave workspace config empty or omit the file entirely.
workspace:
profile: "DEFAULT" # Uses ~/.databrickscfgOr use environment variable:
export DATABRICKS_CONFIG_PROFILE="dev"If nothing is specified, the Databricks SDK uses its default authentication chain:
- Environment variables (
DATABRICKS_HOST,DATABRICKS_TOKEN) ~/.databrickscfgdefault profile- Azure CLI (on Azure)
- OAuth flow
If you work with multiple Databricks workspaces, use profiles:
# Configure dev profile
databricks configure --token --profile dev
# Configure prod profile
databricks configure --token --profile prodThis creates ~/.databrickscfg:
[DEFAULT]
host = https://default-workspace.cloud.databricks.com
token = dapi...
[dev]
host = https://dev-workspace.cloud.databricks.com
token = dapi...
[prod]
host = https://prod-workspace.cloud.databricks.com
token = dapi...Method 1: In Config File
workspace:
profile: "dev"Method 2: Environment Variable
export DATABRICKS_CONFIG_PROFILE="dev"
dbx_test run --remoteMethod 3: Multiple Config Files
# config/test_config_dev.yml
workspace:
profile: "dev"
# config/test_config_prod.yml
workspace:
profile: "prod"Run with:
dbx_test run --remote --config config/test_config_dev.yml
dbx_test run --remote --config config/test_config_prod.yml~/.databrickscfg:
[DEFAULT]
host = https://your-workspace.cloud.databricks.com
token = dapi...config/test_config.yml:
# Leave workspace section empty or omit entirely
cluster:
size: "M"
spark_version: "13.3.x-scala2.12"Run:
dbx_test run --remote~/.databrickscfg:
[dev]
host = https://dev-workspace.cloud.databricks.com
token = dapi...config/test_config.yml:
workspace:
profile: "dev"Run:
dbx_test run --remoteNo config file needed!
export DATABRICKS_HOST="https://your-workspace.cloud.databricks.com"
export DATABRICKS_TOKEN="dapi..."
dbx_test run --remote --tests-dir testsIf using Azure Databricks with Azure CLI:
# Login to Azure
az login
# The SDK will automatically use Azure CLI authentication
dbx_test run --remote- Log into your Databricks workspace
- Click your user profile → User Settings
- Go to Access Tokens tab
- Click Generate New Token
- Give it a name and optional expiration
- Copy the token (you won't see it again!)
# Configure CLI with token
databricks configure --token
# Or set environment variable
export DATABRICKS_TOKEN="your-token-here"- Use Databricks CLI profiles for local development
- Use environment variables in CI/CD pipelines
- Set token expiration dates
- Use separate tokens for dev/prod
- Store tokens in secrets managers (Azure Key Vault, AWS Secrets Manager, etc.)
- Commit tokens to version control
- Share tokens between users
- Use admin tokens for automated testing
- Store tokens in plain text config files in repos
- name: Run Databricks Tests
env:
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
DATABRICKS_TOKEN: ${{ secrets.DATABRICKS_TOKEN }}
run: |
dbx_test run --remote- script: |
export DATABRICKS_HOST=$(DATABRICKS_HOST)
export DATABRICKS_TOKEN=$(DATABRICKS_TOKEN)
dbx_test run --remote
displayName: 'Run Tests'withCredentials([
string(credentialsId: 'databricks-host', variable: 'DATABRICKS_HOST'),
string(credentialsId: 'databricks-token', variable: 'DATABRICKS_TOKEN')
]) {
sh 'dbx_test run --remote'
}Solution 1: Configure Databricks CLI
databricks configure --tokenSolution 2: Set environment variables
export DATABRICKS_HOST="https://your-workspace.cloud.databricks.com"
export DATABRICKS_TOKEN="dapi..."Solution 3: Add to config file
workspace:
host: "https://your-workspace.cloud.databricks.com"
token: "dapi..."Check your ~/.databrickscfg file:
cat ~/.databrickscfgCreate the profile:
databricks configure --token --profile devGenerate a new token and update:
databricks configure --token- Ensure your token has the necessary permissions
- Check that your user has access to the workspace
- Verify the workspace URL is correct
The framework now seamlessly integrates with Databricks CLI, making authentication much easier:
✅ No manual token management ✅ Supports multiple workspaces via profiles ✅ Works with Azure CLI authentication ✅ Compatible with CI/CD pipelines ✅ Follows Databricks SDK best practices
Just configure once with databricks configure --token and you're ready to test! 🚀