Databricks

Databricks Asset Bundles: Asset Distribution and Per-Environment Management

2026-03-26
更新: 2026-03-27
NicheeLab Editorial Team

Databricks Asset Bundles (DABs) provide a way to define Databricks assets — jobs, DLT pipelines, notebooks, ML models, and more — as code, and deploy them consistently across multiple environments (dev / staging / prod). You describe asset configuration in a databricks.yml file, and use the Databricks CLI bundle commands to validate, deploy, run, and destroy them.

This article walks through the core concepts of DABs, the databricks.yml structure, per-environment targets, the main CLI commands, and how to choose between DABs, Terraform, and Repos.

What are Databricks Asset Bundles?

DABs are the tool that brings "Infrastructure as Code (IaC) + Application as Code" to Databricks. Historically, Databricks development meant creating jobs and pipelines manually in the UI, and copying them by hand when moving between environments (dev → staging → prod). DABs let you define those same assets in YAML, manage them in Git, and deploy them automatically through CI/CD.

DABs can manage the following kinds of assets:

  • Jobs (Workflows / Lakeflow Jobs)
  • DLT pipelines (Delta Live Tables pipeline definitions)
  • MLflow experiments and models
  • Notebooks and Python scripts
  • Dashboards (Databricks SQL Dashboards)
  • Schemas and volumes (UC objects)

Anatomy of a databricks.yml

The databricks.yml placed at the project root is built from the following main sections:

bundle:
  name: my-etl-pipeline

variables:
  catalog_name:
    description: "Target catalog"
    default: "dev_catalog"
  warehouse_id:
    description: "SQL Warehouse ID"

workspace:
  root_path: /Workspace/Users/${workspace.current_user.userName}/.bundle/${bundle.name}/${bundle.target}

resources:
  jobs:
    daily_etl:
      name: "daily-etl-${bundle.target}"
      schedule:
        quartz_cron_expression: "0 0 2 * * ?"
        timezone_id: "Asia/Tokyo"
      tasks:
        - task_key: ingest
          notebook_task:
            notebook_path: ./src/ingest.py
          new_cluster:
            spark_version: "14.3.x-scala2.12"
            num_workers: 4
            node_type_id: "i3.xlarge"
        - task_key: transform
          depends_on:
            - task_key: ingest
          notebook_task:
            notebook_path: ./src/transform.py
          new_cluster:
            spark_version: "14.3.x-scala2.12"
            num_workers: 8

  pipelines:
    dlt_pipeline:
      name: "dlt-pipeline-${bundle.target}"
      target: "${var.catalog_name}.bronze"
      libraries:
        - notebook:
            path: ./src/dlt_definitions.py

targets:
  dev:
    mode: development
    default: true
    variables:
      catalog_name: "dev_catalog"
  staging:
    variables:
      catalog_name: "staging_catalog"
  prod:
    mode: production
    variables:
      catalog_name: "prod_catalog"
    run_as:
      service_principal_name: "prod-deployer-sp"

Designing targets (environments)

The targets section is how you deploy the same asset definitions to different environments. Each target can override variables, permissions, and the run-as identity (run_as).

Target attributeDescriptionExample dev valueExample prod value
modedevelopment / productiondevelopment (name prefixing, restricted permissions)production (run_as required, production permissions)
variablesEnvironment-specific variable valuescatalog_name: dev_catalogcatalog_name: prod_catalog
run_asIdentity that runs the assetsOmitted (deploying user)service_principal_name specified
workspace.hostTarget workspace URLdev-workspace.cloud.databricks.comprod-workspace.cloud.databricks.com
defaultWhether this is the default targettrueOmitted (false)

In development mode, resource names are automatically prefixed with [dev username], so multiple developers can deploy bundles to the same workspace without name collisions. In production mode, run_as is required, and using a service principal is the recommended best practice.

Key CLI commands

CommandDescriptionTypical use
databricks bundle validateSyntax and reference checks against databricks.ymlCI/CD PR checks, local validation
databricks bundle deploy -t devDeploy assets to the specified targetCreate or update jobs and DLT pipelines
databricks bundle run -t dev daily_etlRun a deployed job immediatelySmoke testing, manual triggers
databricks bundle destroy -t devRemove every deployed assetCleaning up validation environments
databricks bundle summaryShow a summary of what will be deployedFinal review before deploying

Environment variables and secrets management

Declare variables inside databricks.yml. Override their defaults per target, or inject values at CLI runtime via the --var flag.

# Inject variables at CLI runtime
databricks bundle deploy -t prod --var="catalog_name=prod_catalog"

# Example in a CI/CD pipeline (GitHub Actions)
- name: Deploy to prod
  run: |
    databricks bundle deploy -t prod \
      --var="catalog_name=${{ secrets.PROD_CATALOG }}" \
      --var="warehouse_id=${{ secrets.PROD_WAREHOUSE_ID }}"

Best practice: do not write secrets (passwords, API keys, etc.) into databricks.yml. Store them in a Databricks Secret Scope and read them inside notebooks via dbutils.secrets.get.

DABs vs Terraform vs Repos comparison

CriterionDatabricks Asset BundlesTerraformRepos (Git integration)
Main targetsJobs / DLT / notebooks / ML modelsWorkspaces / cluster policies / UC / networkingVersion control of notebooks and Python files
Definition languageYAML (databricks.yml)HCL (.tf)Git-only (no declarative definitions)
Per-environment managementtargets + variablesworkspaces + tfvarsBranch-based (manual switching)
State managementManaged by the Databricks workspaceManaged via S3 / Azure Blob / Terraform CloudNone (just Git history)
CI/CD integrationDatabricks CLI + GitHub Actions / Azure DevOpsterraform plan/apply + a CI/CD toolGit push → auto-sync
Deletion managementbundle destroy removes everything at onceterraform destroy removes everything at onceManual deletion only
Learning curveLow (YAML + Databricks CLI)Medium-high (HCL plus state-management concepts)Low (just Git operations)

What the exam asks about

DABs show up on the Data Engineer Professional and administration-focused exams.

  • "How do I deploy jobs and DLT pipelines consistently across dev/staging/prod?" → DABs (configure targets)
  • "How do I swap the catalog name per environment in databricks.yml?" → Override variables in each target
  • "How do I pin the job run identity for production deploys?" → Specify a service principal via run_as
  • "When do I use Terraform vs DABs?" → Terraform for infrastructure, DABs for application assets

Check your understanding

Data Engineer Professional

問題 1

A team builds Databricks ETL jobs and DLT pipelines in a development environment and wants to deploy them safely to production. In production, the jobs must run as a service principal and use a different catalog name. Which approach is best?

  1. Build the jobs in the UI in dev and copy them to prod using Export/Import
  2. Define the jobs and DLT pipelines in databricks.yml with Databricks Asset Bundles, and switch the catalog name and run_as via targets (dev/prod) at deploy time
  3. Define the jobs as Terraform resources and run terraform apply against each environment
  4. Use Databricks Repos to sync notebooks from Git and create the jobs manually

正解: B

DABs are purpose-built for deploying jobs and DLT pipelines across environments. You can switch the catalog name via variables in each target, and pin the identity with run_as. UI copying is error-prone, Terraform is aimed at the infrastructure layer (it can define jobs, but DABs is more specialised for Databricks assets), and Repos only handles version control — it does not include job definitions.

Frequently Asked Questions

How should I choose between Databricks Asset Bundles (DABs) and Terraform?

DABs are purpose-built for distributing Databricks assets — jobs, pipelines, notebooks, ML models — and managing per-environment differences. Terraform, by contrast, is better suited to infrastructure-level resources such as workspaces, cluster policies, networking, and UC metastores. In practice, the recommended pattern is a two-layer setup: build the underlying infrastructure with Terraform, and manage the application assets running on top of it (jobs, DLT pipelines, ML models, etc.) with DABs.

Where do I define environment variables in databricks.yml?

Use the variables block inside the targets section to swap values per environment. For example, if you want to vary the catalog name or cluster size across dev/staging/prod, declare catalog_name in variables and override the default in each target. You can also inject values from the command line via the --var flag in CI/CD pipelines.

How do I completely remove assets deployed with DABs?

Use the databricks bundle destroy command. It removes every asset the bundle manages — jobs, DLT pipelines, deployed notebooks, and so on — from the workspace. Data produced by the jobs (Delta tables, for example) is not deleted. The --auto-approve flag skips the confirmation prompt, but manual confirmation is recommended in production.

Check what you learned with practice questions

Practice with certification-focused question sets

無料で問題を解いてみる
Author

NicheeLab Editorial Team

NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.


Related articles
Databricks

Databricks Certifications: All 7 Exams, Difficulty & Study Plan (2026)

Complete guide to all 7 Databricks certifications — Data Eng...

Databricks

Databricks Exam Difficulty Ranking: All 7 Certs Compared (2026)

Every Databricks certification ranked by difficulty, with st...

Databricks

Databricks Study Guide: Fastest Pass Route & Time Estimates (2026)

How to pass Databricks certifications efficiently. Official ...

Databricks

Databricks Data Engineer Associate: Complete Guide (2026)

Domain-by-domain breakdown of the Databricks Certified Data ...

Databricks

Databricks Data Engineer Professional: Complete Guide (2026)

Tactics for the Databricks Certified Data Engineer Professio...

Browse all Databricks articles (110)
© 2026 NicheeLab All rights reserved.