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:
For Linux or macOS, you have Homebrew installed.
Note
If you cannot use Homebrew, for other ways to install the CLI, see Install or update the Databricks CLI.
For Windows, you have curl and
unzip
installed.Note
If you cannot use
curl
, for other ways to install the CLI, see Install or update the Databricks CLI.You have a Databricks personal access token that maps to your Databricks user account for the target Databricks workspace that you want to run the Databricks CLI against.
Note
This tutorial assumes that you want to use a Databricks personal access token for authentication. To configure the CLI to use other Databricks authentication types, see Authentication for the Databricks CLI.
Complete the following steps:
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.
Run the CLI’s
configure
command to configure authentication between the CLI and your workspace:databricks configure
At the first prompt,
Databricks Host: https://
, enter your workspace URL and pressEnter
.At the second prompt,
Personal Access Token
, enter your personal access token value and pressEnter
.
Next steps
After you set up the Databricks CLI:
To learn how to use the CLI, see Basic usage for the Databricks CLI.
If the CLI does not run or produces unexpected results, see Verify your CLI installation.
To configure the CLI to work with multiple Databricks workspaces as well as with Databricks accounts, see Configuration profiles for the Databricks CLI.
To use Databricks authentication types other than Databricks personal access token authentication, see Authentication for 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:
In the Databricks workspace user interface, on the sidebar, click Compute.
Click the name of the existing cluster that you want to install the Databricks CLI on.
Click Start, if the cluster is not already running.
After the cluster is running, on the Apps tab, click Web Terminal. A Bash-style terminal appears, and
curl
is already installed.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.
Run the CLI’s
configure
command to configure authentication between the CLI and your workspace:databricks configure
At the first prompt,
Databricks Host: https://
, enter your workspace URL and pressEnter
.At the second prompt,
Personal Access Token
, enter your personal access token value and pressEnter
.
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.