Note
此信息适用于 Databricks CLI 版本 0.205 及更高版本。 The Databricks CLI is in Public Preview.
Databricks CLI use is subject to the Databricks License and Databricks Privacy Notice, including any Usage Data provisions.
The configure
command within the Databricks CLI enables you to authenticate the Databricks CLI with Azure Databricks using Azure Databricks personal access tokens or Microsoft Entra ID (formerly Azure Active Directory) tokens.
Note
As a security best practice, when you authenticate with automated tools, systems, scripts, and apps, Databricks recommends that you use personal access tokens belonging to service principals instead of workspace users. 若要为服务主体创建令牌,请参阅管理服务主体的令牌。
Note that this article covers only Azure Databricks personal access token and Microsoft Entra ID token authentication for enabling the calling of workspace-level commands. 有关其他身份验证配置选项,请参阅为 Databricks CLI 设置身份验证。
databricks configure
在 ~/.databrickscfg
文件中配置配置文件。 A configuration profile is a collection of settings that contains authentication information such as an Azure Databricks workspace URL and an access token value.
配置文件具有编程名称,例如 DEFAULT
、DEV
或 PROD
。 将多个配置文件添加到 .databrickscfg
文件后,可以通过在命令的选项中指定目标连接配置文件的名称,在各个工作区中快速运行命令 --profile
。 如果你不在支持 --profile
选项的命令中指定该选项,该命令默认将使用 DEFAULT
连接配置文件。
例如,你有一个名为 DEV
的连接配置文件引用用于开发工作负载的 Azure Databricks 工作区,以及一个名为 PROD
的独立连接配置文件,该连接配置文件引用用于生产工作负载的不同 Azure Databricks 工作区。
若要获取有关现有配置文件的信息,请使用 auth
命令组。
可以通过设置环境变量 .databrickscfg
来更改 DATABRICKS_CONFIG_FILE
文件的默认路径。
如果在非交互模式下调用此命令,它将从 stdin 读取令牌。 必须使用标志或DATABRICKS_HOST
环境变量指定--host
主机。
databricks configure [flags]
选项
--configure-cluster
配置群集的提示
--host string
Databricks 工作区主机 URL
工作区主机 URL 是每个工作区的 URL,格式 https://adb-<workspace-id>.<random-number>.azuredatabricks.net
为 。 To get the per-workspace URL, see Per-workspace URL.
--profile string
要配置的连接配置文件的名称。 (default "DEFAULT")
Examples
以下示例为默认配置文件配置身份验证:
databricks configure
以下示例为特定配置文件配置身份验证:
databricks configure --profile my-profile
以下示例使用特定主机配置身份验证:
databricks configure --host https://my-workspace.cloud.databricks.com
以下示例使用群集配置配置身份验证:
databricks configure --configure-cluster
Global flags
--debug
是否启用调试日志记录。
-h
或 --help
显示 Databricks CLI、相关命令组或相关命令的帮助。
--log-file
字符串
一个字符串,表示要将输出日志写入到的文件。 如果未指定此标志,则默认会将输出日志写入到 stderr。
--log-format
格式
日志格式类型或 text
json
。 默认值是 text
。
--log-level
字符串
一个表示日志格式级别的字符串。 如果未指定,则禁用日志格式级别。
-o, --output
类型
命令输出类型或 text
json
。 默认值是 text
。
-p, --profile
字符串
用于运行命令的文件中配置文件 ~/.databrickscfg
的名称。 如果未指定此标志,则如果存在,则使用命名 DEFAULT
的配置文件。
--progress-format
格式
显示进度日志的格式: default
、 append
、 inplace
或 json
-t, --target
字符串
如果适用,要使用的捆绑包目标
创建配置文件
若要创建配置文件,请 configure
运行以下命令:
databricks configure --host <workspace-url>
该命令会提示你输入映射到指定 的 Azure Databricks 个人访问令牌或 <workspace-url>
:
✔ Databricks Token:
输入访问令牌后,该访问令牌默认会存储在 Linux 或 macOS 上的 ~/.databrickscfg
文件中,或 Windows 上的 %USERPROFILE%\.databrickscfg
文件中。 该文件包含名为 DEFAULT
的默认连接配置文件条目:
[DEFAULT]
host = <workspace-url>
token = <access-token>
若要为连接配置文件使用其他名称而不是 DEFAULT
,请将 --profile
选项添加到 configure
命令,例如:
databricks configure --host <workspace-url> --profile <profile-name>
Tip
可以在 Tab
或 --profile
之后按 -p
以显示可供选择的现有可用配置文件的列表,而不是手动输入配置文件名称。
指定的连接配置文件中的所有现有主机和令牌信息将由新的主机和令牌信息覆盖。