The Simplest Way to Make Azure Key Vault and Spanner Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Running azure key vault and spanner together lets teams store cloud secrets in one place while querying a global database. Your app reads a secret or key from Microsoft Azure and uses it to log in to Google Cloud Spanner. Multi-cloud setups often grow messy as more engineers join a project. Teams put keys in one cloud and run databases in another cloud. Without a clear plan, engineers waste hours fixing broken login scripts. A simple setup links identity rules across both clouds with zero manua

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Running azure key vault and spanner together lets teams store cloud secrets in one place while querying a global database. Your app reads a secret or key from Microsoft Azure and uses it to log in to Google Cloud Spanner.

Multi-cloud setups often grow messy as more engineers join a project. Teams put keys in one cloud and run databases in another cloud. Without a clear plan, engineers waste hours fixing broken login scripts. A simple setup links identity rules across both clouds with zero manual key sharing.

How azure key vault and spanner share identity and data

First, your app logs in to Microsoft Azure using its cloud identity. Azure checks the role of the app to see if it can read secrets. If the check passes, the vault sends the stored Google Cloud credentials or keys back to the app. Then, the app uses those details to open a session with the Spanner database.

You can also use workload identity federation to avoid storing static keys at all. In this flow, Azure issues a token to your app or user. Google Cloud checks that token and grants a temporary role for the database. Meanwhile, the vault still holds encryption keys or app secrets needed for your business logic.

Data flows between the app and the database over encrypted network paths. When the database returns rows, your app can use vault keys to decrypt sensitive fields. Every step relies on strict role checks in both cloud consoles.

Common failure modes and how to scope roles

The biggest risk in a two-cloud setup is a shared service account key. Teams often put one static Google Cloud key inside an Azure secret. Soon, every developer and test app reads that same secret to run database queries. When someone deletes a table, the database logs only show the shared account name.

Broad permissions create another major problem for security teams. An engineer might need to read a few rows to fix a bug. Instead, the shared key gives them full write rights across every database instance. Static keys also sit on laptops when developers copy them out of the vault for local testing.

Azure Key Vault + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix this, split your roles by task and team. Give each app its own identity in Azure with access to only one vault secret. In Google Cloud, map each identity to a narrow database role. Read-only users should only get select rights on specific tables.

Next, lock down the network paths between your clouds. Do not open your vault to public internet traffic from any source. Set firewall rules so only known app subnets can request secrets. Turn on audit logs in both clouds so you can track every secret read and database query.

Protecting sensitive data during live queries

Even with scoped roles, raw queries can expose customer data to support staff. Databases often hold emails, phone numbers, card numbers, and national IDs. When an engineer runs a test query, those fields show up in plain text on their screen.

Teams should add controls that inspect query results before they reach the user. Data masking rewrites matched fields in results so raw phone numbers or card numbers stay hidden. Combined with per-user query logging, you get a complete trail of who ran which command and when.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Should we store static Google Cloud service account keys in Azure Key Vault?

Avoid static keys whenever you can. Use workload identity federation for keyless logins, and only store static keys when legacy apps require them.

How often should teams rotate secrets used for Spanner logins?

If you must store a database credential in the vault, rotate it on a strict schedule. Automated rotation jobs can create a new key, update the secret, and delete the old key.

How do we track which engineer ran a specific Spanner query?

Stop sharing a single vault secret across your whole engineering team. Tie every database session to an individual user identity so audit logs record the exact person.

The query runs. The emails stay hidden.