我想使用databricks cli:
databricks clusters list
但这需要一个手动步骤,该步骤要求与用户进行互动工作:
databricks configure --token
是否有一种无需手动干预即可使用databricks cli的方法,以便您可以将其作为ci / cd管道的一部分运行?
答案 0 :(得分:1)
如上文@usingnamespace和官方文档所述:
CLI 0.8.0及更高版本支持环境变量,环境变量设置优先于配置文件中的设置。
DATABRICKS_HOST
DATABRICKS_USERNAME
DATABRICKS_PASSWORD
DATABRICKS_TOKEN
这样,不仅您将不会将敏感数据公开在明文文件(〜/ .databrickscfg )中,而且您无需添加其他代码到您的脚本。
答案 1 :(得分:1)
这是脚本的PowerShell版本。
write-host Configure databricks access
$Env:DATABRICKS_CONFIG_FILE = "$(System.DefaultWorkingDirectory)/.databrickscfg"
Set-Location $(System.DefaultWorkingDirectory)
Set-Content .databrickscfg "[DEFAULT]"
Add-Content .databrickscfg "host = https://westeurope.azuredatabricks.net/"
Add-Content .databrickscfg "token = $(db-token)"
答案 2 :(得分:0)
以下bash脚本自动配置了databricks cli:
echo "configuring databrick-cli authentication"
declare DATABRICKS_URL="https://westeurope.azuredatabricks.net"
declare DATABRICKS_ACCESS_TOKEN="authentication_token_generated_from_databricks_ux"
declare dbconfig=$(<~/.databrickscfg)
if [[ $dbconfig = *"host = "* && $dbconfig = *"token = "* ]]; then
echo "file [~/.databrickscfg] is already configured"
else
if [[ -z "$DATABRICKS_URL" || -z "$DATABRICKS_ACCESS_TOKEN" ]]; then
echo "file [~/.databrickscfg] is not configured, but [DATABRICKS_URL],[DATABRICKS_ACCESS_TOKEN] env vars are not set"
else
echo "populating [~/.databrickscfg]"
> ~/.databrickscfg
echo "[DEFAULT]" >> ~/.databrickscfg
echo "host = $DATABRICKS_URL" >> ~/.databrickscfg
echo "token = $DATABRICKS_ACCESS_TOKEN" >> ~/.databrickscfg
echo "" >> ~/.databrickscfg
fi
fi
答案 3 :(得分:0)
您可以只导出变量DATABRICKS_HOST和DATABRICKS_TOKEN。有了这些变量,您就不需要配置文件。