Creating a Secret Scope in Databricks
Creating a secret scope in Databricks is essential for securely managing sensitive information such as credentials. Here’s how you can create a secret scope using the Databricks CLI or the Databricks workspace UI.
Using the Databricks CLI
To create a secret scope using the Databricks CLI (version 0.205 and above), follow these steps:
- Open your terminal and ensure you have the Databricks CLI installed and configured.
- Create a secret scope by running the command:
databricks secrets create-scope
Replace
with your desired scope name. By default, the scope is created with MANAGE permission for the user who created it. - Verify the scope creation by listing all scopes using:
databricks secrets list-scopes
Using the Databricks Workspace UI
To create a secret scope via the Databricks workspace UI:
- Access your Databricks workspace by navigating to
https://
. Replace#secrets/createScope
with your workspace URL. - Enter the scope name and select the manage principal (either Creator or All workspace users) to define who has MANAGE permission.
- Click Create to finalize the scope creation.
Frequently Asked Questions
FAQs
- Q: What are the requirements for a secret scope name?
A: Secret scope names must be unique within a workspace, consist of alphanumeric characters, dashes, underscores, @, and periods, and cannot exceed 128 characters. They are case insensitive.
- Q: How do I add secrets to a scope?
A: You can add secrets using the Databricks CLI with commands like
databricks secrets put-secret
or via the Databricks SDK for Python. - Q: Can I use Azure Key Vault for secret scopes?
A: Yes, you can create an Azure Key Vault-backed secret scope in Databricks. This involves using Azure Key Vault to store and manage your secrets.
- Q: Who can read Databricks secrets?
A: Administrators, secret creators, and users granted permission can read Databricks secrets.
- Q: How do I access secrets in a notebook?
A: You can access secrets in a notebook using the Databricks Utilities, specifically
dbutils.secrets.get()
. - Q: Can I delete a secret scope?
A: Yes, you can delete a secret scope using the Databricks CLI command
databricks secrets delete-scope
. This action deletes all secrets and ACLs associated with the scope. - Q: What happens to secrets when a scope is deleted?
A: When a secret scope is deleted, all secrets and ACLs (Access Control Lists) applied to that scope are also deleted.
Bottom Line
Creating a secret scope in Databricks is a straightforward process that enhances security by allowing you to store and manage sensitive information securely. Whether using the CLI or the UI, Databricks provides flexible options for managing secrets effectively.