Azure Databricks now supports a service credential object in Unity Catalog, enabling secure and governed access to external cloud services like Azure Key Vault. A service credential encapsulates a long-term cloud credential, allowing Databricks to access these services while adhering to enterprise-grade governance and security standards. This blog focuses on how to configure service credentials in Unity Catalog to enable Role-Based Access Control (RBAC) for Azure Key Vault integration.
Service credentials offer several advantages when integrating Azure Databricks with Azure Key Vault:
Before you begin, ensure the following:
The Access Connector acts as a managed identity that facilitates secure communication between Databricks and Azure Key Vault.
az databricks access-connector create --name "databricks-access-connector-<CUSTOM DESCRIPTION>" \
--resource-group "my-resource-group" \
--location "eastus"
Note: It is recommended to add a custom description for future reference.
2. Assign the Key Vault Secrets User role to the Access Connector:
A service credential in Unity Catalog securely encapsulates the long-term credential required to access external services like Azure Key Vault.
CREATE SERVICE CREDENTIAL ag_kv_service_credential
TYPE AZURE_KEY_VAULT
OPTIONS (
vault_url 'https://<your-key-vault-name>.vault.azure.net/'
);
This command links your Databricks workspace with your Azure Key Vault using the specified service credential.
Once the service credential is configured, you can programmatically retrieve secrets from Azure Key Vault using Databricks notebooks:
from azure.keyvault.secrets import SecretClient
# Get the service credential provider
credential = dbutils.credentials.getServiceCredentialsProvider('ag_kv_service_credential')
# Initialize the SecretClient
secret_client = SecretClient(
vault_url="https://<your-key-vault-name>.vault.azure.net/",
credential=credential
)
# Retrieve a secret
secret = secret_client.get_secret("<your-seceret-name-in-keyvalut>")
# Print secret details
print(secret.name)
print(secret.value)
This approach ensures that secrets are accessed securely without exposing sensitive credentials in your codebase.
Issue |
Solution |
Permission Denied Errors |
Verify that the Access Connector has been assigned the Key Vault Secrets User role. |
Incorrect Secret Retrieval |
Ensure that the secret name matches exactly (case-sensitive). |
Credential Initialization Failure |
Check if the service credential is correctly configured in Unity Catalog. |
The introduction of service credentials in Unity Catalog revolutionizes how Azure Databricks integrates with external cloud services like Azure Key Vault. By leveraging this feature, organizations can securely govern access to secrets while fully embracing RBAC for enhanced security and compliance. This approach simplifies secret management, reduces operational overhead, and aligns with modern cloud governance practices.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.