Skip to content

[Server] Add Azure service principal and GCP service account key credentials - #2179

Draft
timothyw553 wants to merge 1 commit into
unitycatalog:mainfrom
timothyw553:stack/azure-gcp-credential-types
Draft

timothyw553 wants to merge 1 commit into
unitycatalog:mainfrom
timothyw553:stack/azure-gcp-credential-types

Conversation

@timothyw553

@timothyw553 timothyw553 commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Part of #47 (Azure Data Lake Storage support) and the roadmap item "Azure + GCP external location & credential support at S3 parity". PR 1 of 4 in a stack:

  1. this PR: credential types, API, CLI, schema step
  2. [Server] Vend Azure SAS tokens from storage credentials #2180 [Server] Vend Azure SAS tokens from storage credentials
  3. [Server] Vend GCS tokens from storage credentials #2181 [Server] Vend GCS tokens from storage credentials
  4. [Docs] Point cloud storage setup at credentials and external locations #2182 [Docs] Point cloud storage setup at credentials and external locations

Motivation

Storage credentials only accept aws_iam_role, so an admin cannot onboard ADLS or GCS storage through the API. Those clouds are reachable only through the legacy adls.* / gcs.* entries in server.properties, which need a service maintainer and a server restart, keep cloud secrets on the server host, and return 501 when an external location on abfss:// or gs:// is used for vending.

API change

api/all.yaml gains two cloud identities on CreateCredentialRequest, UpdateCredentialRequest and CredentialInfo, with the same names and fields as Databricks Unity Catalog so existing clients and SDKs understand them:

  • azure_service_principal {directory_id, application_id, client_secret}: a Microsoft Entra ID service principal with access to the storage account. This follows the preferred option in the "[Decision] Azure Storage Credential in UC OSS" design doc (Yi Li; the doc is still marked DRAFT): service principal first; managed identity needs a different workflow because the server is not a first-party Azure service.
  • gcp_service_account_key {email, private_key_id, private_key}: a service account key with access to the bucket, the fields of the key JSON file. Chosen for consistency with the Azure decision: customer-managed secret, no server-side configuration, works on-prem. Note that Databricks Unity Catalog has deprecated this key type in favor of Databricks-managed service accounts, a first-party feature UC OSS has no equivalent of; a secretless option for UC OSS (impersonating a service account the bucket owner shares with the server) is a possible follow-up.

Responses use AzureServicePrincipalResponse and GcpServiceAccountKeyResponse, which have no secret field, mirroring AwsIamRoleRequest / AwsIamRoleResponse. The regenerated api/Models/*.md and api/README.md are included.

Server

  • CredentialDAO stores the new identities in the existing typed JSON blob; toCredentialInfo returns the identity without the secret. CredentialType now knows which URL schemes each cloud reaches.
  • CredentialRepository requires exactly one cloud identity on create and at most one on update, checks the fields are non-blank, and rejects changing a credential's cloud (external locations bind a credential to URLs of its cloud).
  • ExternalLocationRepository rejects a credential that cannot reach the location's URL, on create and on update of either the URL or the credential. file: URLs accept any credential, as the existing tests already rely on.
  • Schema step V3__add_azure_gcp_credential_types for H2, MySQL and PostgreSQL widens uc_credentials.credential_type (an ENUM, or a CHECK constraint on PostgreSQL) to the new values. Effect files come from build/sbt updateSchemaDumps on all three databases. An existing database takes the step through bin/start-uc-server --upgrade-schema; Hibernate's update does not alter existing columns.
  • Vending through the new credentials still returns UNIMPLEMENTED in this PR; the next two PRs add it.

CLI

bin/uc credential create|update gain --azure_directory_id, --azure_application_id, --azure_client_secret (must be given together) and --gcp_service_account_key_file <path>, which reads client_email, private_key_id and private_key from the key JSON file.

Tests

  • BaseCredentialCRUDTest (SDK and CLI): create/get/list/update/delete for both new types, exactly-one-identity and blank-field validation, cloud cannot change on update.
  • SdkCredentialCRUDTest.testGetAndListNeverReturnSecrets reads the raw HTTP responses and checks neither client_secret nor the private key appears.
  • BaseExternalLocationCRUDTest.testExternalLocationCredentialMustMatchUrlCloud: scheme/cloud mismatch on create and update, file: accepts any.
  • io.unitycatalog.server.migrate.* pass on H2, PostgreSQL 18 and MySQL 8.4 with the new step.
  • Full server/test and cli/test pass locally.

Compatibility

Additive API change; existing AWS credentials, the aws_iam_role field and the legacy per-bucket configuration are unchanged. New validation: an AWS credential with a blank role_arn is now rejected at create time (it could never vend).

This pull request and its description were written by Isaac.

…entials

Storage credentials only accepted aws_iam_role, so ADLS and GCS storage
could be reached only through the legacy adls.* and gcs.* entries in
server.properties, which need a service maintainer and a restart and
keep cloud secrets on the server host. Part of unitycatalog#47.

Add azure_service_principal {directory_id, application_id, client_secret}
and gcp_service_account_key {email, private_key_id, private_key} to the
credential API, with the same names as Databricks Unity Catalog, store
them in the existing typed JSON blob of uc_credentials, and return the
identity without the secret on get and list.

A create request must carry exactly one cloud identity and an update at
most one, and the cloud cannot change afterwards: external locations
bind a credential to URLs of its cloud, so creating or updating an
external location now rejects a credential that cannot reach the URL
(file: URLs accept any). The CLI gets --azure_directory_id,
--azure_application_id, --azure_client_secret and
--gcp_service_account_key_file.

uc_credentials.credential_type is an enum (H2, MySQL) or a check
constraint (PostgreSQL) in the versioned schema, so schema step V3 widens
it to the new values; an existing database takes it through
bin/start-uc-server --upgrade-schema. The effect files come from
build/sbt updateSchemaDumps on all three databases.

Vending through these credentials still returns UNIMPLEMENTED; the next
PRs in the stack add it for Azure and GCS.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Timothy Wang <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant