Databricks CLI tutorial

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 Databricks command-line interface (also known as the Databricks CLI) utility provides an easy-to-use interface to automate the Databricks platform from your terminal, command prompt, or automation scripts.

This article demonstrates how to use your local development machine to get started quickly with the Databricks CLI. See What is the Databricks CLI?.

The following hands-on tutorial assumes:

Complete the following steps:

  1. Install the CLI, depending on your operating system:

    From your terminal, run the following two Homebrew commands to install the CLI:

    brew tap databricks/tap
    brew install databricks
    

    From your terminal running as an administrator, run the following command to use curl to install the CLI:

    curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/main/install.sh | sh
    

    Note

    To view the script’s contents before you run it, see the install.sh file in the Databricks CLI Setup repository in GitHub.

  2. Run the CLI’s configure command to configure authentication between the CLI and your workspace:

    databricks configure
    
  3. At the first prompt, Databricks Host: https://, enter your workspace URL and press Enter.

  4. At the second prompt, Personal Access Token, enter your personal access token value and press Enter.

Next steps

After you set up the Databricks CLI:

Run the Databricks CLI on a cluster

If you want to install, configure, and run the Databricks CLI on a Databricks cluster instead of on your local machine, the fastest way to do this is as follows:

  1. In the Databricks workspace user interface, on the sidebar, click Compute.

  2. Click the name of the existing cluster that you want to install the Databricks CLI on.

  3. Click Start, if the cluster is not already running.

  4. After the cluster is running, on the Apps tab, click Web Terminal. A Bash-style terminal appears, and curl is already installed.

  5. Run the following command to use curl to install the CLI:

    curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/main/install.sh | sh
    

    Note

    To view the script’s contents before you run it, see the install.sh file in the Databricks CLI Setup repository in GitHub.

  6. Run the CLI’s configure command to configure authentication between the CLI and your workspace:

    databricks configure
    
  7. At the first prompt, Databricks Host: https://, enter your workspace URL and press Enter.

  8. At the second prompt, Personal Access Token, enter your personal access token value and press Enter.

Note that whenever you click Start to start the cluster, you must then reinstall and reconfigure the CLI on the cluster. This is because a new virtual machine is provisioned each time you click Start, and the new virtual machine does not include the CLI by default.