Basic usage for the Databricks CLI

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.

This article shows you how to list Databricks CLI command groups and commands, display Databricks CLI help, and work with Databricks CLI output. See What is the Databricks CLI?.

This article assumes that you have already installed the Databricks CLI and set up the CLI for authentication. See:

List CLI command groups

You list the command groups by using the --help or -h option. For example:

databricks -h

List CLI commands

You list the commands for any command group by using the --help or -h option. For example, to list the clusters commands:

databricks clusters -h

Display CLI command help

You display the help for a command by using the --help or -h option. For example, to display the help for the clusters list command:

databricks clusters list -h

Use jq to parse CLI JSON output

Some Databricks CLI commands output responses are formatted as JSON. In many cases, the Databricks CLI formats the JSON output so that it is easier to read. However, sometimes it can be useful to parse out parts of the JSON instead of listing the entire response. For example, to list just the display name of a Databricks cluster with the specified cluster ID, you can use the utility jq:

databricks clusters get 1234-567890-abcde123 | jq -r .cluster_name

Output:

My-11.3-LTS-Cluster

You can install jq for example on macOS by using Homebrew with brew install jq or on Windows by using Chocolatey with choco install jq. For more information on jq, see the jq Manual.

JSON string parameters

The format of string parameters is handled differently in JSON depending on your operating system:

You must enclose JSON string parameters in double quotes, and you must enclose the entire JSON payload in single quotes. Some examples:

'{"cluster_id": "1234-567890-abcde123"}'
'["20230323", "Amsterdam"]'

You must enclose JSON string parameters and the entire JSON payload in double quotes, and the double-quote characters inside the JSON payload must be preceded by \. Some examples:

"{\"cluster_id\": \"1234-567890-abcde123\"}"
"[\"20230323\", \"Amsterdam\"]"

Proxy server configuration

To route Databricks CLI requests and responses through a proxy server, set the HTTPS_PROXY environment variable on the machine where the Databricks CLI is installed to the proxy server’s URL.

To set environment variables, see your operating system’s documentation.

Global flags

The following flags are available to all Databricks CLI commands. Note that some flags do not apply to some commands. For more information, see the command’s documentation.

Flag

Description

-h or --help

Display help for the Databricks CLI or the related command group or the related command.

-e or --environment string

A string representing the bundle environment to use if applicable for the related command.

--log-file

A string representing the to write output logs to. If this flag is not specified then the default is to write output logs to stderr.

--log-format

text to write output logs to text or json to write output logs to JSON. If this flag is not specified then output logs are written as text.

--log-level

A string representing the log format level. If not specified then the log format level is disabled.

-o or --output

text to write output as text or json to write output as JSON. If this flag is not specified then output is written as text.

-p or --profile

A string representing the named configuration profile to use within your .databrickscfg file. If this flag is not specified then the DEFAULT named profile is used if one exists. You can press Tab after --profile or -p to display a list of existing available configuration profiles to choose from instead of entering the configuration profile name manually.

--progress-format

The format for progress logs to display (default (the default) or append or inplace or json).