| name | databricks-deploy-integration |
| description | Deploy Databricks jobs and pipelines with Asset Bundles.
Use when deploying jobs to different environments, managing deployments,
or setting up deployment automation.
Trigger with phrases like "databricks deploy", "asset bundles",
"databricks deployment", "deploy to production", "bundle deploy".
|
| allowed-tools | Read, Write, Edit, Bash(databricks:*) |
| version | 1.0.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
Databricks Deploy Integration
Overview
Deploy Databricks workloads using Asset Bundles for environment management.
Prerequisites
- Databricks CLI v0.200+
- Asset Bundle project structure
- Workspace access for target environments
Instructions
Step 1: Project Structure
my-databricks-project/
├── databricks.yml # Main bundle configuration
├── resources/
│ ├── jobs.yml # Job definitions
│ ├── pipelines.yml # DLT pipeline definitions
│ └── clusters.yml # Cluster policies
├── src/
│ ├── notebooks/ # Databricks notebooks
│ │ ├── bronze/
│ │ ├── silver/
│ │ └── gold/
│ └── python/ # Python modules
│ └── etl/
├── tests/
│ ├── unit/
│ └── integration/
├── fixtures/ # Test data
└── conf/
├── dev.yml # Dev overrides
├── staging.yml # Staging overrides
└── prod.yml # Production overrides
Step 2: Main Bundle Configuration
bundle:
name: data-platform
variables:
catalog:
description: Unity Catalog name
default: dev_catalog
warehouse_id:
description: SQL Warehouse ID
default: ""
include:
- resources/*.yml
workspace:
host: ${DATABRICKS_HOST}
artifacts:
etl_wheel:
type: whl
path: ./src/python
build: poetry build
targets:
dev:
default: true
mode: development
variables:
catalog: dev_catalog
workspace:
root_path: /Users/${workspace.current_user.userName}/.bundle/${bundle.name}/dev
staging:
mode: development
variables:
catalog: staging_catalog
workspace:
root_path:
Step 3: Job Definitions
resources:
jobs:
etl_pipeline:
name: "${bundle.name}-etl-${bundle.target}"
description: "Main ETL pipeline for ${var.catalog}"
tags:
environment: ${bundle.target}
team: data-engineering
managed_by: asset_bundles
schedule:
quartz_cron_expression: "0 0 6 * * ?"
timezone_id: "America/New_York"
pause_status: ${bundle.target == "dev" ? "PAUSED" : "UNPAUSED"}
email_notifications:
on_failure:
- oncall@company.com
no_alert_for_skipped_runs: true
parameters:
- name: catalog
default: ${var.catalog}
- name: run_date
default: ""
tasks:
- task_key: bronze_ingest
job_cluster_key: etl_cluster
Step 4: Deployment Commands
databricks bundle validate
databricks bundle validate -t staging
databricks bundle validate -t prod
databricks bundle deploy -t dev
databricks bundle deploy -t staging
databricks bundle deploy -t prod
databricks bundle deploy -t staging --resource etl_pipeline
databricks bundle destroy -t dev --auto-approve
Step 5: Run Management
databricks bundle run -t staging etl_pipeline
databricks bundle run -t staging etl_pipeline \
--params '{"catalog": "test_catalog", "run_date": "2024-01-15"}'
databricks bundle summary -t prod
databricks bundle summary -t prod --output json | jq '.resources.jobs'
Step 6: Blue-Green Deployment
from databricks.sdk import WorkspaceClient
import time
def blue_green_deploy(
w: WorkspaceClient,
job_name: str,
new_config: dict,
rollback_on_failure: bool = True,
) -> dict:
"""
Deploy job using blue-green strategy.
1. Create new job version
2. Run validation
3. Switch traffic
4. Remove old version (or rollback)
"""
jobs = [j for j in w.jobs.list() if j.settings.name == job_name]
old_job = jobs[0] if jobs else None
new_name = f"{job_name}-new"
new_config["name"] = new_name
new_job = w.jobs.create(**new_config)
try:
run = w.jobs.run_now(job_id=new_job.job_id)
result = w.jobs.get_run(run.run_id).wait()
if result.state.result_state != "SUCCESS":
raise Exception(f"Validation failed: {result.state.state_message}")
if old_job:
w.jobs.update(
job_id=old_job.job_id,
new_settings={"name": f"{job_name}-old"}
)
w.jobs.update(
job_id=new_job.job_id,
new_settings={"name": job_name}
)
old_job:
w.jobs.delete(job_id=old_job.job_id)
{: , : new_job.job_id}
Exception e:
rollback_on_failure:
w.jobs.delete(job_id=new_job.job_id)
Output
- Deployed Asset Bundle
- Jobs created in target workspace
- Environment-specific configurations applied
Error Handling
| Issue | Cause | Solution |
|---|
| Permission denied | Missing run_as permissions | Configure service principal |
| Resource conflict | Name collision | Use unique names with target suffix |
| Artifact not found | Build failed | Run databricks bundle build first |
| Validation error | Invalid YAML | Check bundle syntax |
Examples
Environment Comparison
databricks bundle summary -t dev --output json > dev.json
databricks bundle summary -t prod --output json > prod.json
diff <(jq -S . dev.json) <(jq -S . prod.json)
Rollback Procedure
git checkout HEAD~1 -- databricks.yml resources/
databricks bundle deploy -t prod --force
Resources
Next Steps
For webhooks and events, see databricks-webhooks-events.