• Task
  • Version ยท 6.0
  • Create

Use Azure Key Vault secrets with Liquibase

Last updated: October 14, 2026

Store sensitive Liquibase configuration values, such as database passwords, in Azure Key Vault and reference them from your Liquibase configuration. Liquibase resolves each reference at command time using your Azure environment's credentials, so no secret values appear in your configuration files or version control. This feature is included in the Liquibase Azure extension, which ships with Liquibase Secure.

Procedure

1

Grant your Azure identity access to the vault

The Azure identity that runs Liquibase needs read access to the vault items you reference. Grant access with RBAC roles (recommended) or a legacy access policy. Both are supported.

RBAC roles: In the Azure portal, open your Key Vault and go to Access control (IAM) > Add > Add role assignment. Assign the role for each item type you use, scoped to the vault, to the identity that runs Liquibase. For detailed steps, see Provide access to Key Vault keys, certificates, and secrets with Azure RBAC in the Microsoft documentation.

Item type

Role

Secrets

Key Vault Secrets User

Keys

Key Vault Crypto User

Certificates

Key Vault Certificate User

Legacy access policies: If your vault uses the classic access policy model instead of RBAC, grant the Get permission for each item type you use. See Assign a Key Vault access policy in the Microsoft documentation.

2

Provide Azure credentials

Liquibase authenticates with the Azure SDK's DefaultAzureCredential. Credentials come from your Azure environment, never from Liquibase configuration files. Use whichever method fits where Liquibase runs:

Environment variables (CI/CD pipelines, containers):

loading

loading

Azure CLI (local development): If you have the Azure CLI installed, sign in with az login. Liquibase reuses your Azure CLI session automatically, so you do not need a service principal or environment variables. Your Azure account needs the vault access described in Step 1.

Managed Identity (Azure-hosted workloads such as VMs, App Service, and AKS): Enable a managed identity on the Azure resource and grant it vault access as in Step 1. Authentication happens automatically.

3

Reference vault items in your Liquibase configuration

Replace a sensitive value with a comma-separated reference. Each reference has a prefix that selects the item type, followed by the vault URL, the item name, and an optional version. You can reference all three Azure Key Vault item types. Most users only need secrets.

Item type

Prefix

Resolved value

Secret

azure-key-vault-secret

The secret's value

Key

azure-key-vault-key

The key's public part as a PEM-encoded PUBLIC KEY block

Certificate

azure-key-vault-cert

The certificate as a PEM-encoded X.509 CERTIFICATE block

Note: The azure-key-vault-key prefix returns public keys only (RSA and EC, including HSM variants). Liquibase rejects private, symmetric (oct), and other non-public key material with an error.

Be sure to:

  • Replace your_vault_name with your Key Vault name. For example, my-company-vault

  • Replace your_secret_name with the name of the secret in the vault. For example, db-password

liquibase.command.password=azure-key-vault-secret,https://your_vault_name.vault.azure.net,your_secret_name

loading

loading

loading

Pin a specific version: Add the version identifier as an optional fourth segment. When you omit it, Liquibase retrieves the latest version.

Be sure to:

  • Replace your_version_id with the version identifier of the vault item

liquibase.command.password=azure-key-vault-secret,https://your_vault_name.vault.azure.net,your_secret_name,your_version_id

Set a default vault URL: If most references point at one vault, set liquibase.azure.keyVault.url (environment variable: LIQUIBASE_AZURE_KEY_VAULT_URL) and leave the vault URL segment empty. An inline vault URL always takes precedence over the default.

liquibase.azure.keyVault.url=https://your_vault_name.vault.azure.net
liquibase.command.password=azure-key-vault-secret,,your_secret_name

Keys and certificates use the same format with their own prefixes.

Be sure to:

  • Replace your.property with the property that receives the key's PEM value

  • Replace your.other.property with the property that receives the certificate's PEM value

  • Replace your_key_name with the name of the key in the vault

  • Replace your_certificate_name with the name of the certificate in the vault

your.property=azure-key-vault-key,https://your_vault_name.vault.azure.net,your_key_name
your.other.property=azure-key-vault-cert,https://your_vault_name.vault.azure.net,your_certificate_name
4

Verify the resolution

Run any Liquibase command that uses the configured value.

Be sure to:

  • Replace your_changelog_file with the path to your changelog file. For example, changelog.sql

loading

At the fine log level, Liquibase records the resolution without exposing the value. The log line names the configuration key the way you supplied it, such as LIQUIBASE_COMMAND_PASSWORD for an environment variable or --password for a CLI parameter:

LIQUIBASE_COMMAND_PASSWORD resolved to an Azure Key Vault Secrets secret.

The first vault call in a run also logs Acquiring Azure Key Vault credentialโ€ฆ at the info level. Secret values are masked in logs and never appear in error messages.

Troubleshooting

Failed to retrieve secret from vault

Failed to retrieve secret from vault 'https://your_vault_name.vault.azure.net'. Verify the RBAC role assignment (or legacy access policy) on the calling identity. (cause: HTTP 403)

Liquibase deliberately reports the same message whether the item is missing or access was denied, so that item names cannot leak into logs. The cause segment identifies the failure:

Cause

Meaning

HTTP 403

The identity authenticated but has no role assignment or access policy on the vault

HTTP 404

The item name is wrong or the item was deleted

UncheckedIOException

The vault URL is wrong or the vault host is unreachable

CredentialUnavailableException

No credentials found in the environment. Set the environment variables, run az login, or configure Managed Identity

Invalid Azure Key Vault Secrets reference

Invalid Azure Key Vault Secrets reference. Expected 'azure-key-vault-secret,<vault-url>,<name>[,<version>]' but found 2 comma-separated segment(s).

The reference has too few or too many comma-separated segments. Check for a missing segment or a stray comma.

Azure Key Vault Secrets requires a vault URL

The vault URL segment is empty and no default vault URL is configured. Add the URL inline or set liquibase.azure.keyVault.url.

Vault URL must be an https:// URL

The vault URL segment must start with https://. Only the scheme is validated, so vaults in sovereign and government clouds work with their native hostnames.

The reference is used literally as the password

If your database rejects the connection and the failure shows the full reference string as the attempted password, Liquibase never resolved the reference. This happens on Liquibase versions that do not include Azure Key Vault support. No warning is logged on those versions. Upgrade to Liquibase Secure 6.0 or later and confirm that liquibase --version lists internal/extensions/liquibase-azure.jar.

Requires the Liquibase Azure extension and a Liquibase Secure license

Add a valid Liquibase Secure license key to your configuration. Without a valid license the command fails with this error rather than continuing with the reference unresolved, so the value is never read from the vault.