bundle command group

Note

This information applies to Databricks CLI versions 0.205 and above, which are in Public Preview. To find your version of the Databricks CLI, run databricks -v.

The bundle command group within the Databricks CLI enables you to programmatically validate, deploy, and run Databricks workflows such as Databricks jobs, Delta Live Tables pipelines, and MLOps Stacks. See What are Databricks Asset Bundles?.

Important

Before you use the Databricks CLI, be sure to set up the Databricks CLI and set up authentication for the Databricks CLI.

You run bundle commands by appending them to databricks bundle. To display help for the bundle command, run databricks bundle -h.

Create a bundle from a project template

To create a Databricks Asset Bundle by using the default Databricks Asset Bundle template for Python, run the bundle init command as follows, and then answer the on-screen prompts:

databricks bundle init

To create a Databricks Asset Bundle by using a non-default Databricks Asset Bundle template, run the bundle init command as follows:

databricks bundle init <project-template-local-path-or-url> \
--project-dir="</local/path/to/project/template/output>"

See also:

Display the bundle configuration schema

To display the Databricks Asset Bundle configuration schema, run the bundle schema command, as follows:

databricks bundle schema

To output the Databricks Asset Bundle configuration schema as a JSON file, run the bundle schema command and redirect the output to a JSON file. For example, you can generate a file named bundle_config_schema.json within the current directory, as follows:

databricks bundle schema > bundle_config_schema.json

Validate a bundle

To validate that your bundle configuration files are syntactically correct, run the bundle validate command from the same directory as the bundle configuration files, as follows:

databricks bundle validate

Sync a bundle’s tree to a workspace

Use the bundle sync command to do one-way synchronization of a bundle’s file changes within a local filesystem directory, to a directory within a remote Databricks workspace.

Note

bundle sync commands cannot synchronize file changes from a directory within a remote Databricks workspace, back to a directory within a local filesystem.

databricks bundle sync commands work in the same way as databricks bundle commands and are provided as a productivity convenience. For command usage information, see sync command group.

Generate bundle configuration for an existing job or pipeline

You can use the bundle generate command to generate resource configuration for a job or pipeline that already exists in your Databricks workspace. This command generates a *.yml file for the job or pipeline in the resources folder of the bundle project and also downloads any notebooks referenced in the job or pipeline configuration. Currently only jobs with notebook tasks are supported by this command.

Important

The bundle generate command is provided as a convenience to autogenerate resource configuration. However, when this configuration is included in the bundle and deployed, it creates a new resource and does not update the existing resource unless bundle deployment bind has first been used on the resource.

Run the bundle generate command as follows:

databricks bundle generate [job|pipeline] --existing-[job|pipeline]-id [job-id|pipeline-id]

For example, the following command generates a new hello_job.yml file in the resources bundle project folder containing the YAML below, and downloads the simple_notebook.py to the src project folder.

databricks bundle generate job --existing-job-id 6565621249
# This is the contents of the resulting hello_job.yml file.
resources:
  jobs:
    6565621249:
      name: Hello Job
      format: MULTI_TASK
      tasks:
        - task_key: run_notebook
          existing_cluster_id: 0704-xxxxxx-yyyyyyy
          notebook_task:
            notebook_path: ./src/simple_notebook.py
            source: WORKSPACE
          run_if: ALL_SUCCESS
      max_concurrent_runs: 1

Bind bundle resources

The bundle deployment bind command allows you to link bundle-defined jobs and pipelines to existing jobs or pipelines in the Databricks workspace so that they become managed by Databricks Asset Bundles. If you bind a resource, existing Databricks resources in the workspace will be updated based on configuration defined in the bundle it is bound to after the next bundle deploy.

Tip

It’s a good idea to confirm the bundle workspace before running bind.

databricks bundle deployment bind [job|pipeline-key] [job|pipeline-id]

For example, the following command binds the resource hello_job to its remote counterpart in the workspace. The command outputs a diff and allows you to deny the resource binding, but if confirmed, any updates to the job definition in the bundle are applied to the corresponding remote job when the bundle is next deployed.

databricks bundle deployment hello_job 6565621249

Use bundle deployment unbind if you want to remove the link between the job or pipeline in a bundle and its remote counterpart in a workspace.

databricks bundle deployment unbind [job|pipeline-key]

Deploy a bundle

To deploy any specified local artifacts to the remote workspace, run the bundle deploy command from the same directory as the bundle configuration files (which is also known as the bundle root). If no command options are specified, the default environment as declared within the bundle configuration files is used, as follows:

databricks bundle deploy

Tip

You can run databricks bundle commands outside of the bundle root. If so, you can specify the bundle root path by setting the BUNDLE_ROOT environment variable. If this environment variable is not set, databricks bundle commands attempt to find the bundle root by searching within the current working directory.

To deploy the artifacts within the context of a specific environment, specify the -e (or --environment) option along with the environment’s name as declared within the bundle configuration files. For example, for an environment declared with the name development, run the following command:

databricks bundle deploy -e development

Run a bundle

To run a specific job or pipeline, run the bundle run command from the same directory as the bundle configuration files. You must specify the job or pipeline declared within the bundle configuration files. If the -e (or --environment) option is not specified, the default environment as declared within the bundle configuration files is used. For example, to run a job named hello_job within the context of the default environment, run the following command:

databricks bundle run hello_job

To run a job named hello_job within the context of an environment declared with the name development, run the following command:

databricks bundle run -e development hello_job

If you want to cancel and restart an existing job run or pipeline update, use the --restart flag:

databricks bundle run --restart

Destroy a bundle

To delete jobs, pipelines, and artifacts that were previously deployed, run the bundle destroy command from the same directory as the bundle configuration files. The following command deletes all previously-deployed jobs, pipelines, and artifacts that are defined in the bundle configuration files:

databricks bundle destroy

By default, you are prompted to confirm permanent deletion of the previously-deployed jobs, pipelines, and artifacts. To skip these prompts and perform automatic permanent deletion, add the --auto-approve option to the bundle destroy command.