Sub topic 1
What Asset Bundles Are and Why to Use Them
Prerequisites
This chapter assumes basic familiarity with Databricks workspaces, notebooks, jobs, YAML, Git, and command-line tools. You also need permission to create jobs in a Databricks workspace.
What Asset Bundles Are
A Databricks Asset Bundle is a project directory that describes Databricks resources as source-controlled configuration. The configuration can define jobs, pipelines, permissions, code files, and libraries.
The Databricks CLI reads the bundle and deploys its resources to a workspace. This is infrastructure as code: the desired project state is written in files instead of created only through a web form.
Bundles make deployments repeatable. Git records changes, code review catches mistakes, and the same project can target development and production workspaces with different settings.
> callout note > A bundle describes deployment configuration. It does not replace the notebook or application code that the deployed resource runs.
Installing the CLI and Authenticating
Install the current Databricks CLI using your operating system's supported package method. Then authenticate to the workspace that will receive the deployment:
databricks auth login --host https://your-workspace.example.comThe command creates a local CLI profile. Use that profile when validating or deploying a bundle. In CI/CD, prefer a service principal or another non-interactive identity rather than a personal login.
Anatomy of `databricks.yml`
The root file identifies the bundle, declares variables, and selects deployment targets. An include entry loads resource definitions from other YAML files.
bundle:
name: my_project
include:
- resources/*.yml
targets:
dev:
mode: development
default: true
workspace:
host: https://your-dev-workspace.example.comA target is a named configuration for one deployment context. Development mode is useful for isolated testing. Production targets commonly add stricter permissions and a service identity.
Defining a Job Resource
A resource file can define a job independently from the root configuration:
resources:
jobs:
daily_etl:
name: daily_etl
tasks:
- task_key: ingest
notebook_task:
notebook_path: ../src/ingest.pyThe path is relative to the resource file. The CLI resolves this definition and creates or updates the corresponding Databricks job.
Exercise
Why keep a job definition in Git instead of creating it only in the workspace?
Show answer
Git provides repeatable deployments, reviewable changes, and a history of the job configuration.