Skip to content

Customer-held encryption keys on Azure Postgres Flexible Server

Ihor SeleznovUpdated 8 min readAnnouncements

Enterprise customers ask us to let them hold the encryption key for their own data, because their compliance requirements demand it. As Preetham Reddy, our CEO, puts it, "it's an absolute deal breaker if the database vendor doesn't provide them the ability to choose their own encryption keys." On Azure Database for PostgreSQL that wasn't possible across tenants until cross-tenant customer-managed keys reached general availability on 29 September 2026.

It's the same pressure behind our own SOC 2 work. We included Confidentiality, beside Security and Availability, in the SOC 2 Type II examination we're preparing TechFabric for in 2027 (our SOC 2 post). We included it because, when customers trust us with their data, availability and confidentiality are the two they ask about next. A key the customer holds is the strongest answer a product on Azure can give.

Saying yes still has a price. The key sits in the customer's own Microsoft Entra tenant and the provider's server encrypts their data with it. That costs engineering time, probably a dedicated server for that customer, and a kind of outage the provider's on-call engineers can't fix. If the customer revokes the key, their database goes offline within the hour and nobody on the provider's side can bring it back.

Who shares a server

The key belongs to the server. A Flexible Server has one dataEncryption setting with one primary key URI (Data encryption at rest), so if customers share a server, separated by schema or by a tenant_id column, none of them can have a key of their own.

It's a shape we design on purpose. On the quoting platform we designed for a pool and landscaping distributor, every row in PostgreSQL would carry the path of the dealer that owns it. Row-level security would allow a row only when the caller's path is an ancestor of it, so a dealer sees its own projects and the distributor sees all of them. That's the right design for a network of branches and dealers, and it's exactly the one where no single dealer could hold a key of its own.

For a product that pooled every tenant into one database from day one, saying yes means a dedicated server for that customer, with its own compute, backups, upgrades and monitoring, and a migration to get their rows onto it. That's the real cost of the deal, and we'd expect it to be bigger than the key work. A product that already gives its largest customers a server each is in a much better position, because there cross-tenant keys are a configuration change on servers it already runs separately.

So the conversation we'd have before anyone writes a line of setup is about the customer's tier.

How we'd build it

No secret crosses between the tenants, and that's the reason we'd trust the design. The link is workload identity federation in Microsoft Entra, with a multitenant app on the provider's side joined to a user-assigned managed identity by a federated credential. We'd keep both in the same infrastructure code as the server, because the app ends up installed in every customer's tenant and is production infrastructure from the first install.

Provider: multitenant app and managed identity, in code

Customer: installs the app as a service principal

Customer: grants it access to a key in their vault

Customer: sends back the key identifier

Provider: Postgres server created with the customer's key

Customer disables the key and the server goes inaccessible

Provider: alert fires, runbook calls the customer's key administrator

How we'd split the work between the two tenants, with the provider's managed identity reaching the customer's key through an app the customer installs, so the provider's Postgres server is created with the customer's key.

The customer's half runs in their own tenant, and we'd send it to them as a short script with the app ID filled in, so their security team reviews three commands instead of working the steps out from the docs.

Their vault needs soft delete and purge protection and has to be in the server's region, and we'd ask for a 4,096-bit RSA key, the size Microsoft recommends. They send back the key identifier, and we'd create the server with it and the multitenant app's client ID as --federated-client-id, which Azure needs to treat the key as cross-tenant.

Then two habits we'd hold from the first server. The key URI stays versionless, so a rotation in the customer's vault is picked up instead of pinning the server to an old version. The customer's rotation procedure keeps the old version enabled for at least two hours while the server re-encrypts, as Microsoft asks. And the pipeline that deploys the server tests its encryption settings on every run, since a Bicep update that leaves out primaryFederatedIdentityClientId quietly becomes a non-cross-tenant configuration.

What we'd agree before anyone signs

Most of the limits can't be fixed once the server exists, so we'd go through them with the customer before anyone signs. The encryption mode is set when the server is created, so an existing customer moves by point-in-time restore onto a new server built with their key. Geo-redundant backup needs a second vault in the backup region, which the customer runs for us. Long-term retention backups aren't supported on cross-tenant servers at all, so a contract that promises multi-year retention needs another answer before this design fits. And one multitenant app holds at most 20 federated credentials, which decides early how identities map to customers.

Revocation needs a contract clause as much as a runbook. If the key is disabled or deleted, or the customer removes the app's access or tightens their vault firewall, the server goes Inaccessible, generally within 60 minutes, and can take another 60 to return to Ready once access comes back. Nothing the provider does in its own tenant shortens either window.

So before the first customer goes live we'd alert on the server's Resource Health and on Key Vault access failures in the Activity Log, so the team hears it from Azure and not from a support ticket. The runbook would start with how support reaches the customer's key administrator, by name and out of hours, and the contract would say who owns the downtime when the customer's key becomes unavailable. Then we'd rehearse a disable and re-enable on a sandbox server with the customer's security team, and time it.

Copies of the data outside Postgres

A customer's key encrypts one Postgres server at rest, its write-ahead log, logs and backups included. It does nothing for the other copies of that customer's data a product usually has, such as a search index, a cache, exports in Blob Storage, an analytics copy in a Databricks lakehouse or a Lakebase database. A customer who revokes the key expecting their data to go dark everywhere will find it still readable in each of those.

We'd map every store that holds the customer's data as part of the data governance work around it, and say in the security questionnaire exactly which stores their key protects. And it changes nothing about who can read data inside the running database, which is still the application's roles and row-level security.

When we'd build it

When a specific customer's security team asks for it, with the dedicated server and the second vault priced into that deal. Before starting we'd get their key administrator's name, their Azure regions, and whether they need geo-redundant or long-term backups, because those three answers decide whether the setup fits at all.

For a company running its own data in its own tenant, ordinary customer-managed keys, or Microsoft's default service-managed keys, give the same encryption without a second tenant or an outage nobody in-house can fix. For a product already moving towards dedicated infrastructure for enterprise customers, it's one more option on that tier, and one we'd build into the platform once.

Frequently asked questions

What happens if the provider deletes the managed identity that reaches the key?

The server loses access to the key and goes Inaccessible, the same as a revocation. Creating a new identity with the same name doesn't fix it. The provider has to recover the deleted identity, or create a new one, register it on the multitenant app as a federated identity credential in place of the old one and update the server to use it, then wait around an hour for the server to revalidate the key. The customer's grant stays on the app's service principal, so their side doesn't change.

Does a read replica use the customer's key too?

Yes, and it needs its own setup. A replica encrypted with a customer-managed key needs that key in a vault in the replica's region, reached by a user-assigned identity created in the same region, so a replica in a second region is one more vault the customer runs.

Does the customer's key vault need public network access?

No. Microsoft recommends disabling public access on the vault and allowing trusted Microsoft services to bypass its firewall, which is what lets the Postgres server keep reaching the key.

Where we do this work