Databricks CLI tutorial

Note

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

For information beyond this tutorial about Databricks CLI versions 0.200 and above, see the Databricks CLI reference.

The Databricks command-line interface (also known as the Databricks CLI) utility provides an easy-to-use interface to automate the Azure Databricks platform from your terminal, command prompt, or automation scripts.

This article demonstrates how to quickly get started with the Databricks CLI.

The following hands-on tutorial assumes:

  • You have curl installed.
  • You have an Azure Databricks personal access token that maps to your Azure Databricks user account for the target Azure Databricks workspace that you want to run the Databricks CLI against.
  • If you are using Linux or macOS, you are running a Linux-style terminal, such as bash or zsh or the macOS Terminal app.
  • If you are using Windows, you are running a Linux-style terminal, such as the Windows Subsystem for Linux (WSL), or Git BASH in Git for Windows.

Complete the following steps:

  1. From your terminal, 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

    For Linux or macOS, if an error message states that /usr/local/bin is not writable, then run the command again with sudo.

  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 an Azure Databricks cluster instead of on your local machine, the fastest way to do this is as follows:

  1. In the Azure 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. Continue with the procedure at the beginning of this article to install, configure, and run the CLI on the cluster.

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.