Condividi tramite


Interfaccia della riga di comando dei segreti (legacy)

Importante

Questa documentazione è stata ritirata e potrebbe non essere aggiornata.

Queste informazioni si applicano alle versioni legacy dell'interfaccia della riga di comando di Databricks 0.18 e successive. Databricks consiglia di usare invece la versione 0.205 o successiva dell'interfaccia della riga di comando di Databricks più recente. Vedere Che cos'è l'interfaccia della riga di comando di Databricks?. Per trovare la versione dell'interfaccia della riga di comando di Databricks, eseguire databricks -v.

Per eseguire la migrazione dall'interfaccia della riga di comando di Databricks versione 0.18 o successiva all'interfaccia della riga di comando di Databricks versione 0.205 o successiva, vedere Migrazione dell'interfaccia della riga di comando di Databricks.

È possibile eseguire sottocomandi dell'interfaccia della riga di comando dei segreti di Databricks aggiungendoli a databricks secrets. Questi sottocomandi chiamano l'API Segreti.

Per altre informazioni sui segreti, vedere Gestione dei segreti.

Nota

L'interfaccia della riga di comando dei segreti richiede l'interfaccia della riga di comando di Databricks 0.7.1 o versione successiva.

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.

Creare un ambito dei segreti

Per visualizzare la documentazione sull'utilizzo, eseguire databricks secrets create-scope --help.

databricks secrets create-scope --scope my-scope

In caso di esito positivo, non viene visualizzato alcun output.

Per usare l'interfaccia della riga di comando di Databricks per creare un ambito segreto supportato da Azure Key Vault, eseguire databricks secrets create-scope --help per visualizzare informazioni sulle opzioni aggiuntive --scope-backend-type, --resource-ide --dns-name . Per altre informazioni, vedere Segreti.

consente di eliminare un segreto

Per visualizzare la documentazione sull'utilizzo, eseguire databricks secrets delete --help.

databricks secrets delete --scope my-scope --key my-key

In caso di esito positivo, non viene visualizzato alcun output.

Revocare un ACL per un'entità

Per visualizzare la documentazione sull'utilizzo, eseguire databricks secrets delete-acl --help.

databricks secrets delete-acl --scope my-scope --principal someone@example.com

In caso di esito positivo, non viene visualizzato alcun output.

Eliminare un ambito dei segreti

Per visualizzare la documentazione sull'utilizzo, eseguire databricks secrets delete-scope --help.

databricks secrets delete-scope --scope my-scope

In caso di esito positivo, non viene visualizzato alcun output.

Ottenere un ACL per un'entità

Per visualizzare la documentazione sull'utilizzo, eseguire databricks secrets get-acl --help.

databricks secrets get-acl --scope my-scope --principal someone@example.com --output JSON
{
  "principal": "sonmeone@example.com",
  "permission": "MANAGE"
}

Elencare le chiavi segrete archiviate all'interno di un ambito segreto

Per visualizzare la documentazione sull'utilizzo, eseguire databricks secrets list --help.

databricks secrets list --scope my-scope --output JSON
{
  "secrets": [
    {
      "key": "my-key",
      "last_updated_timestamp": 1621284092605
    }
  ]
}

Nota

Non è possibile accedere ai valori segreti usando l'interfaccia della riga di comando di Databricks. Per accedere ai valori dei segreti, è necessario usare l'utilità dei segreti databricks all'interno di un notebook di Databricks.

Elencare gli elenchi di controllo di accesso per un ambito segreto

Per visualizzare la documentazione sull'utilizzo, eseguire databricks secrets list-acls --help.

databricks secrets list-acls --scope my-scope --output JSON
{
  "items": [
    {
      "principal": "someone@example.com",
      "permission": "MANAGE"
    }
  ]
}

Elencare tutti gli ambiti segreti disponibili nell'area di lavoro

Per visualizzare la documentazione sull'utilizzo, eseguire databricks secrets list-scopes --help.

databricks secrets list-scopes --output JSON
{
  "scopes": [
    {
      "name": "my-scope",
      "backend_type": "DATABRICKS"
    }
  ]
}

Creare o aggiornare un segreto

Per visualizzare la documentazione sull'utilizzo, eseguire databricks secrets put --help o databricks secrets write --help.

Esistono tre modi per archiviare un segreto. Il modo più semplice consiste nell'usare l'opzione --string-value . Il segreto verrà archiviato in formato UTF-8 (MB4). È consigliabile prestare attenzione a questa opzione, perché il segreto potrebbe essere archiviato nella cronologia della riga di comando in testo normale.

databricks secrets put --scope my-scope --key my-key --string-value my-value

Oppure:

databricks secrets write --scope my-scope --key my-key --string-value my-value

In caso di esito positivo, non viene visualizzato alcun output.

È anche possibile usare l'opzione --binary-file per fornire un segreto archiviato in un file. Il contenuto del file verrà letto così come è e archiviato come byte.

databricks secrets put --scope my-scope --key my-key --binary-file my-secret.txt

Oppure:

databricks secrets write --scope my-scope --key my-key --binary-file my-secret.txt

In caso di esito positivo, non viene visualizzato alcun output.

Se non si specifica un'opzione, verrà aperto un editor per immettere il segreto. Seguire le istruzioni visualizzate nell'editor per immettere il segreto.

databricks secrets put --scope my-scope --key my-key

Oppure:

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.

Concedere o modificare un elenco di controllo di accesso a un ambito segreto per un'entità

Per visualizzare la documentazione sull'utilizzo, eseguire databricks secrets put-acl --help o databricks secrets write-acl --help.

databricks secrets put-acl --scope my-scope --principal someone@example.com --permission MANAGE

Oppure:

databricks secrets write-acl --scope my-scope --principal someone@example.com --permission MANAGE

In caso di esito positivo, non viene visualizzato alcun output.