Skip to content

Databricks sign-in and privileges

More about how SQDR signs in to Databricks and what it needs there (see Prepare Databricks): the service principal for OAuth, why each privilege is needed, and keeping the Db2 password in Azure Key Vault.

Create the service principal (OAuth only)

Skip this with a personal access token. With OAuth, the Replicator Service connects as a Databricks service principal, with its client ID and an OAuth secret:

  1. Add the service principal to the workspace, as a workspace admin: in the workspace Settings, Identity and access, Service principals, add a new Databricks managed one. (An account admin can do the same in the account console and assign it to the workspace.)
  2. Let it use the compute whose connection details the destination uses (see Create the destination): CAN ATTACH TO on a cluster, or CAN USE on a SQL warehouse.
  3. Generate an OAuth secret on the service principal's Secrets tab. The lifetime is at most 730 days. Under Scopes, keep access to all APIs: the ODBC driver asks for the all-apis scope, and a token can't exceed its secret's scopes. Copy the secret (shown only once) and the client ID (the service principal's application ID). Databricks deletes a secret unused for 90 days.
  4. Grant it the privileges (see Grant the privileges), naming it by its application ID in backticks in place of sqdr_principal.

See Microsoft: Manage service principals and Authorize service principal access to Azure Databricks with OAuth.

Why these privileges

Privilege Why
USE CATALOG, USE SCHEMA To reach the schema at all.
CREATE TABLE The Replicator Service creates the destination tables; the Spark connector creates its work tables (4711<table>) in the same schema.
SELECT, MODIFY The Spark connector reads, merges into, empties (TRUNCATE TABLE) and appends to the destination tables. A table's owner has these already.

Keep the Db2 password in Azure Key Vault

Instead of a CLI-created scope (see Store the Db2 password in a secret), create an Azure Key Vault-backed scope at https://<workspace-url>#secrets/createScope (case-sensitive) and keep the password as a secret in the key vault. See Microsoft: Secret management.