Databricks secret management is easiest to maintain when storage, access, rotation, and incident response are designed together. This checklist explains how to choose between Databricks-backed and Azure Key Vault-backed secret scopes, use secrets from notebooks and jobs, apply least privilege, and verify your setup whenever credentials or platform settings change.
Overview
Secrets include passwords, personal access tokens, API keys, connection strings, and other credentials that should not appear in notebooks, source code, job parameters, or logs. In Databricks, a secret scope provides a named boundary for storing and retrieving secret values. Users and groups are then granted permissions on the scope rather than receiving credentials directly in notebook code.
There are two broad approaches to compare:
| Approach | Best fit | Operational consideration |
|---|---|---|
| Databricks-backed secret scope | Teams that want a workspace-managed location for application and integration secrets | Define ownership, access permissions, naming, and rotation procedures in Databricks governance processes |
| Azure Key Vault-backed secret scope | Organizations that already centralize credential ownership and lifecycle management in Azure Key Vault | Confirm the required Azure identity, vault permissions, workspace configuration, and scope access behavior |
The right choice depends on who owns the credential, where rotation is already performed, and how many workspaces or applications need access. An external vault can support centralized ownership, while a Databricks-backed scope may be simpler for workspace-specific integrations. Treat the table as a decision aid, then verify the current requirements for your workspace, cloud account, and Databricks interface before implementation.
Secret scopes are not a replacement for authorization. A notebook that can read a secret may be able to use the associated service, so scope permissions should be reviewed alongside Unity Catalog permissions, workspace entitlements, cluster access, and job ownership. For related permission checks, see the Databricks Unity Catalog permissions guide.
Checklist by scenario
Creating a new Databricks-backed scope
- Define the owner: Record the team responsible for the scope, the service it supports, and the person or group accountable for rotation.
- Choose a specific name: Use a consistent pattern such as
team-system-environment. Avoid names that reveal secret values or imply broader access than intended. - Separate environments: Keep development, test, and production credentials in separate scopes or otherwise enforce a clear boundary.
- Grant the smallest useful permission: Give read access only to the users, groups, or service principals that must retrieve a value. Reserve write or manage permissions for a small administrative group.
- Document every key: Record the key name, purpose, owning system, rotation method, and dependent notebooks or jobs. Do not record the secret value.
- Test from the real execution identity: A notebook author may have access that the production job identity does not. Validate using the identity that will actually run the workload.
Secret scopes and permissions can be created through the Databricks UI, CLI, or API. Command syntax and permission behavior can vary by CLI generation and platform updates, so use the current Databricks documentation and validate commands in a non-production workspace before applying them broadly.
Connecting an Azure Key Vault-backed scope
- Confirm the vault boundary: Decide whether the vault is dedicated to the workspace, shared by environments, or managed centrally. Make the ownership model explicit.
- Prepare the Azure identity: Identify the managed identity, service principal, or other identity used by the integration. Grant only the vault permissions required to retrieve secrets.
- Check network and workspace prerequisites: Verify that the selected workspace, vault, identity, and networking model are compatible. Private networking and firewall settings can affect access even when permissions appear correct.
- Create the scope with the correct backend: Select the external-vault option and enter the required vault and resource details. Do not create a second copy of the same production credential in a Databricks-backed scope unless there is a documented reason.
- Apply Databricks scope permissions: Vault access and Databricks scope access are separate controls. Review both before testing.
- Run an end-to-end test: Retrieve a non-sensitive test value or use a controlled integration test. Confirm that the production job identity, not only an administrator, can access the intended key.
External key management does not remove the need for Databricks governance. It changes where the value is maintained; it does not automatically grant every notebook or job permission to read it.
Using a secret in a notebook or job
Retrieve a secret at runtime rather than assigning the value in source code. A common Python pattern is:
api_key = dbutils.secrets.get(scope='payments-prod', key='api-key')For Spark configuration or a connection string, substitute the retrieved value into the configuration only where needed. Avoid displaying the variable, embedding it in exception messages, or writing it to a table used for debugging. Job tasks should receive access through their execution identity and scope permissions rather than through plaintext task parameters.
When a workload calls an AI model, vector database, storage service, or external API, review the entire path: secret retrieval, client-library configuration, request logging, retry handling, and monitoring. A secure scope cannot prevent a third-party library from logging a connection string if the application is configured carelessly.
What to double-check
- Access-control model: Confirm who can manage, write, read, or use each scope. Review direct assignments and group membership, including inherited access.
- Identity alignment: Check whether the notebook, interactive cluster, scheduled job, SQL warehouse, or serving workload uses the identity you expected.
- Redaction limits: Secret redaction can reduce accidental display in notebook output, but it is not a guarantee against every form of disclosure. Do not print, persist, transform, or send secrets as a way to test redaction.
- Logs and diagnostics: Inspect cluster logs, job output, application logs, query history, exception traces, and monitoring tools for accidental credential exposure.
- Key naming: Use stable, documented key names. A rotation process is safer when applications refer to a logical key such as
api-keyrather than a value-specific name. - Dependency inventory: Identify every notebook, workflow, library, model-serving integration, and external application that reads the secret.
- Failure behavior: Decide whether a missing or expired secret should fail fast, pause a workflow, or trigger an alert. Silent fallback to an insecure default is not acceptable.
- Audit evidence: Retain records of scope ownership, permission reviews, rotation dates, approvals, and validation results without storing secret values.
If credentials support a workflow, include secret failures in operational testing. The Databricks Workflows troubleshooting guide can help connect authentication failures with retries, dependencies, alerts, and recovery procedures.
Common mistakes
Putting secrets in notebooks or repositories
Hardcoding a credential makes revocation and discovery difficult, especially after a notebook is exported, cloned, or committed. Move the value into an approved secret backend, remove it from code and history where possible, and rotate it if exposure is plausible.
Giving every developer manage access
Broad manage permissions make accidental deletion, replacement, or unauthorized sharing more likely. Separate administrators who manage scopes from workloads that only read them. Use groups and service identities so access remains understandable when team membership changes.
Assuming masking solves exposure
Redaction is a safety aid, not a data-loss prevention strategy. A secret can still be exposed through string concatenation, request payloads, debug logs, generated artifacts, or an external service. Treat every retrieved value as sensitive.
Rotating the value without testing consumers
Rotation can break long-running clusters, cached clients, scheduled jobs, or services that require a restart. Inventory consumers, update the backend, test each critical path, and monitor failures after the change. Where the target system supports overlapping credentials, a staged transition can reduce interruption.
Failing to respond to an exposed secret
If a credential appears in a notebook, log, ticket, or repository, do not rely on deletion alone. Revoke or rotate it, identify affected systems, review access records, remove the exposure from active locations, and document the incident according to your organization’s response process.
When to revisit
Use this checklist before a new workspace or integration goes live, before seasonal planning or access reviews, and whenever a workflow or tool changes. Revisit it immediately after a credential exposure, ownership change, cloud identity change, networking change, or migration between Databricks and Azure Key Vault.
At each review, confirm the current Databricks CLI and UI behavior, supported secret backends, scope permission semantics, workspace settings, identity configuration, and redaction limitations. Platform features and command syntax can change, so avoid copying an old command without testing it in a controlled environment.
A practical rotation runbook is:
- List the credential, owner, backend, key name, consumers, and business impact.
- Confirm the replacement value works with the target service.
- Update the approved secret backend without changing the application’s logical key name when possible.
- Restart or redeploy consumers that cache credentials.
- Run a controlled notebook, job, or service test using the real execution identity.
- Monitor failures, retries, and downstream service responses.
- Revoke the old credential after the transition window, if one was used.
- Record the date, operator, validation result, and next review date.
For AI workloads, make secret review part of the same release discipline used for prompts, retrieval systems, model endpoints, and evaluation jobs. The Databricks RAG application guide and model serving deployment checklist provide useful neighboring checks for integrations that commonly depend on protected credentials.