祕密 CLI (舊版)
重要
此文件已淘汰,且可能未更新。
此資訊適用於舊版 Databricks CLI 0.18 版和更早版本。 Databricks 建議您改用較新的 Databricks CLI 0.205 版或更新版本。 請參閱什麼是 Databricks CLI?。 若要尋找 Databricks CLI 版本,請執行 databricks -v
。
若要從 Databricks CLI 0.18 版或更低版本移轉至 Databricks CLI 0.205 版或更新版本,請參閱 Databricks CLI 移轉。
您可以將 Databricks 秘密 CLI 子命令附加至 來執行 databricks secrets
。 這些子命令會呼叫 秘密 API。
如需秘密的詳細資訊,請參閱 秘密管理。
注意
秘密 CLI 需要 Databricks CLI 0.7.1 或更新版本。
databricks secrets --help
Usage: databricks secrets [OPTIONS] COMMAND [ARGS]...
Utility to interact with secret API.
Options:
-v, --version [VERSION]
--profile TEXT CLI connection profile to use. The default profile is
"DEFAULT".
-h, --help Show this message and exit.
Commands:
create-scope Creates a secret scope.
Options:
--scope SCOPE The name of the secret scope.
--initial-manage-principal The initial principal that can manage the created secret scope.
If specified, the initial ACL with MANAGE permission applied
to the scope is assigned to the supplied principal (user or group).
The only supported principal is the group
"users", which contains all users in the workspace. If not
specified, the initial ACL with MANAGE permission applied to
the scope is assigned to request issuer's user identity.
delete Deletes a secret.
Options:
--scope SCOPE The name of the secret scope.
--key KEY The name of secret key.
delete-acl Deletes an access control rule for a principal.
Options:
--scope SCOPE The name of the scope.
--principal PRINCIPAL The name of the principal.
delete-scope Deletes a secret scope.
Options:
--scope SCOPE The name of the secret scope.
get-acl Gets the details for an access control rule.
Options:
--scope SCOPE The name of the secret scope.
--principal PRINCIPAL The name of the principal.
--output FORMAT JSON or TABLE. Set to TABLE by default.
list Lists all the secrets in a scope.
Options:
--scope SCOPE The name of the secret scope.
--output FORMAT JSON or TABLE. Set to TABLE by default.
list-acls Lists all access control rules for a given secret scope.
Options:
--scope SCOPE The name of the secret scope.
--output FORMAT JSON or TABLE. Set to TABLE by default.
list-scopes Lists all secret scopes.
--output FORMAT JSON or TABLE. Set to TABLE by default.
put Puts a secret in a scope.
Options:
--scope SCOPE The name of the secret scope.
--key KEY The name of the secret key.
--string-value TEXT Read value from string and stored in UTF-8 (MB4) form
--binary-file PATH Read value from binary-file and stored as bytes.
put-acl Creates or overwrites an access control rule for a principal
applied to a given secret scope.
Options:
--scope SCOPE The name of the secret scope.
--principal PRINCIPAL The name of the principal.
--permission [MANAGE|WRITE|READ] The permission to apply.
write Puts a secret in a scope. "write" is an alias for "put".
Options:
--scope SCOPE The name of the secret scope.
--key KEY The name of the secret key.
--string-value TEXT Read value from string and stored in UTF-8 (MB4) form
--binary-file PATH Read value from binary-file and stored as bytes.
write-acl Creates or overwrites an access control rule for a principal
applied to a given secret scope. "write-acl" is an alias for
"put-acl".
Options:
--scope SCOPE The name of the secret scope.
--principal PRINCIPAL The name of the principal.
--permission [MANAGE|WRITE|READ] The permission to apply.
建立秘密範圍
若要顯示使用方式文件,請執行 databricks secrets create-scope --help
。
databricks secrets create-scope --scope my-scope
如果成功,就不會顯示任何輸出。
若要使用 Databricks CLI 建立 Azure 金鑰保存庫 支援的秘密範圍,請執行 databricks secrets create-scope --help
以顯示其他--scope-backend-type
、 --resource-id
和 --dns-name
選項的相關信息。 如需詳細資訊,請參閱 秘密管理。
刪除秘密
若要顯示使用方式文件,請執行 databricks secrets delete --help
。
databricks secrets delete --scope my-scope --key my-key
如果成功,就不會顯示任何輸出。
撤銷主體的訪問控制列表 (ACL)
若要顯示使用方式文件,請執行 databricks secrets delete-acl --help
。
databricks secrets delete-acl --scope my-scope --principal someone@example.com
如果成功,就不會顯示任何輸出。
刪除秘密範圍
若要顯示使用方式文件,請執行 databricks secrets delete-scope --help
。
databricks secrets delete-scope --scope my-scope
如果成功,就不會顯示任何輸出。
取得主體的存取控制列表
若要顯示使用方式文件,請執行 databricks secrets get-acl --help
。
databricks secrets get-acl --scope my-scope --principal someone@example.com --output JSON
{
"principal": "sonmeone@example.com",
"permission": "MANAGE"
}
列出秘密範圍中儲存的秘密金鑰
若要顯示使用方式文件,請執行 databricks secrets list --help
。
databricks secrets list --scope my-scope --output JSON
{
"secrets": [
{
"key": "my-key",
"last_updated_timestamp": 1621284092605
}
]
}
注意
您無法使用 Databricks CLI 來存取秘密值。 若要存取秘密值,您必須在 Databricks 筆記本內使用 Databricks 公用程式 秘密公用程式。
列出機密範圍的 ACL
若要顯示使用方式文件,請執行 databricks secrets list-acls --help
。
databricks secrets list-acls --scope my-scope --output JSON
{
"items": [
{
"principal": "someone@example.com",
"permission": "MANAGE"
}
]
}
列出工作區中的所有可用秘密範圍
若要顯示使用方式文件,請執行 databricks secrets list-scopes --help
。
databricks secrets list-scopes --output JSON
{
"scopes": [
{
"name": "my-scope",
"backend_type": "DATABRICKS"
}
]
}
建立或更新秘密
若要顯示使用方式檔,請執行 databricks secrets put --help
或 databricks secrets write --help
。
有三種方式可以儲存秘密。 最簡單的方式是使用 --string-value
選項;秘密會以UTF-8 (MB4) 形式儲存。 您應該小心使用此選項,因為您的秘密可能會以純文本儲存在命令行歷程記錄中。
databricks secrets put --scope my-scope --key my-key --string-value my-value
或:
databricks secrets write --scope my-scope --key my-key --string-value my-value
如果成功,就不會顯示任何輸出。
您也可以使用 --binary-file
選項來提供儲存在檔案中的秘密。 檔案內容會以目前的形式讀取,並儲存為位元組。
databricks secrets put --scope my-scope --key my-key --binary-file my-secret.txt
或:
databricks secrets write --scope my-scope --key my-key --binary-file my-secret.txt
如果成功,就不會顯示任何輸出。
如果您未指定選項,將會開啟編輯器,讓您輸入秘密。 依照編輯器中顯示的指示輸入秘密。
databricks secrets put --scope my-scope --key my-key
或:
databricks secrets write --scope my-scope --key my-key
# ----------------------------------------------------------------------
# Do not edit the above line. Everything below it will be ignored.
# Please input your secret value above the line. Text will be stored in
# UTF-8 (MB4) form and any trailing new line will be stripped.
# Exit without saving will abort writing secret.
將 ACL 授權或變更給主體以訪問秘密範圍
若要顯示使用方式檔,請執行 databricks secrets put-acl --help
或 databricks secrets write-acl --help
。
databricks secrets put-acl --scope my-scope --principal someone@example.com --permission MANAGE
或:
databricks secrets write-acl --scope my-scope --principal someone@example.com --permission MANAGE
如果成功,就不會顯示任何輸出。