Skip to content

Databricks Asset Bundles: a project template for dev to prod

By Datanest · Published · Updated

Databricks Asset Bundles (DABs) let you describe jobs, pipelines and their settings as YAML in your repository and deploy them with the Databricks CLI. Databricks's current documentation calls the feature Declarative Automation Bundles ("formerly known as Databricks Asset Bundles"); the CLI commands are the same (databricks bundle ...). The point of a template is that the same definition goes to dev and prod, and only a few values change per environment.

This page shows a minimal layout you can copy. It is a starting point, not a complete production setup.

How this was checked. The files below were validated with databricks bundle validate (Databricks CLI v1.28.0, 1 December 2026) for both the dev and the prod target, against a local stub of the workspace API. They have not been deployed to a live workspace, and the values in angle brackets are placeholders you must replace. Run databricks bundle validate in your own workspace before you deploy.

Project layout

my_pipeline/
├── databricks.yml
├── resources/
│   └── daily_ingest.yml
└── src/
    └── ingest.py

databricks.yml

databricks.yml

bundle:
  name: my_pipeline

include:
  - resources/*.yml

variables:
  catalog:
    description: Unity Catalog catalog this environment writes to
    default: dev_catalog

targets:
  dev:
    mode: development
    default: true
    workspace:
      host: https://<dev-workspace-url>

  prod:
    mode: production
    workspace:
      host: https://<prod-workspace-url>
      root_path: /Workspace/Users/<service-principal-application-id>/.bundle/${bundle.name}/${bundle.target}
    variables:
      catalog: prod_catalog
    run_as:
      service_principal_name: "<service-principal-application-id>"

What this does:

  • mode: development prefixes deployed job names with [dev <your user>], tags them as dev and pauses their schedules, so a deploy to dev never starts a production-style schedule by accident.
  • mode: production makes the CLI insist on a fixed workspace.root_path, so only one copy of the bundle is deployed per target. Keep that path in a restricted folder: with a path under /Workspace/Shared the CLI warns that the folder is writable by all workspace users.
  • run_as with a service principal means production jobs do not run as one person's account. Databricks recommends service principals for production deployments.
  • The catalog variable has a default for dev and an override for prod. You can also override it on the command line: --var="catalog=my_catalog".

The job definition

resources/daily_ingest.yml

resources:
  jobs:
    daily_ingest:
      name: daily_ingest
      schedule:
        quartz_cron_expression: "0 0 6 * * ?"
        timezone_id: Europe/Helsinki
      job_clusters:
        - job_cluster_key: main
          new_cluster:
            spark_version: "<runtime-version>"
            node_type_id: "<node-type>"
            num_workers: 2
      tasks:
        - task_key: ingest
          job_cluster_key: main
          notebook_task:
            notebook_path: ../src/ingest.py
            base_parameters:
              catalog: ${var.catalog}

Fill in a supported Databricks Runtime version and a node type for your cloud. databricks clusters spark-versions and databricks clusters list-node-types list what your workspace offers. The notebook path is relative to the resource file, and the task passes the bundle variable to the notebook as a parameter.

src/ingest.py

# Databricks notebook source
dbutils.widgets.text("catalog", "dev_catalog")
catalog = dbutils.widgets.get("catalog")
spark.sql(f"USE CATALOG {catalog}")
print(f"Running against catalog: {catalog}")

The first line, # Databricks notebook source, is required. Without it a .py file is a plain file, and databricks bundle validate fails with "expected a notebook ... but got a file".

Run it

databricks bundle validate -t dev      # check the configuration
databricks bundle deploy   -t dev      # create or update the job in dev
databricks bundle run      -t dev daily_ingest
databricks bundle validate -t prod
databricks bundle deploy   -t prod     # same definition, prod values

Deploying from GitHub Actions

Databricks documents workload identity federation for GitHub Actions: the workflow gets a short-lived OIDC token, so no long-lived Databricks secret is stored in GitHub. The service principal needs a federation policy that matches your repository and environment. See Databricks's "Enable workload identity federation for GitHub Actions" page for the exact subject format, which depends on when the repository was created.

.github/workflows/deploy-prod.yml

name: deploy-prod
on:
  push:
    branches: [main]

permissions:
  id-token: write   # needed for OIDC federation
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: prod
    env:
      DATABRICKS_AUTH_TYPE: github-oidc
      DATABRICKS_HOST: ${{ vars.DATABRICKS_HOST }}
      DATABRICKS_CLIENT_ID: ${{ secrets.DATABRICKS_CLIENT_ID }}   # service principal application ID
    steps:
      - uses: actions/checkout@v4
      - uses: databricks/[email protected]   # pin a release tag; check the releases page for the latest
      - run: databricks bundle validate -t prod
      - run: databricks bundle deploy -t prod

DATABRICKS_CLIENT_ID is the service principal's application ID. Deploy with the same service principal that run_as names in the prod target, or with an identity that has CAN_USE on it. Pull requests are a good place for a separate job that runs databricks bundle validate against a non-production target.

Things that usually go wrong

  1. Production deploys as a person. Set run_as to a service principal and a fixed root_path for prod. Without a service principal, production mode additionally expects run_as and permissions to be set explicitly.
  2. A job created by hand already exists. Bind it to the bundle instead of creating a duplicate:
    databricks jobs list                                   # find the job ID
    databricks bundle generate job --existing-job-id <job-id>
    databricks bundle deployment bind daily_ingest <job-id> -t prod
    After binding, the next bundle deploy updates that existing job in place. bundle generate job currently supports jobs that use notebook tasks.
  3. Environment values hard-coded in notebooks. Pass them as base_parameters from variables, as above.
  4. Variables behave differently at deploy and at run. Bundle variables are resolved when you deploy. Use the same method (--var, BUNDLE_VAR_* or target values) for both deploy and run, and use job parameters for values that change per run.
  5. Dev schedules do not fire. That is development mode working as designed. Unpause a single job explicitly if you need a dev schedule to run.

Want the full pipeline set?

The Databricks CI/CD Accelerator (79 USD) packages the same idea as ready pipeline files: GitHub Actions, Azure DevOps and GitLab CI pipelines for Terraform and for Asset Bundles, dev/staging/prod environment files, a promotion strategy with approval gates, an integration-test stage and a deployment validation script, a rollback playbook and pipeline alert guidance. Its manifest lists Terraform 1.5 or newer and Databricks CLI 0.230 or newer as requirements.

Related: a minimal data contract template.