The Simplest Way to Make Azure Functions and GCP Secret Manager Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use azure functions and gcp secret manager to run code across clouds. The function app reads keys from Google Cloud at run time. This workflow keeps secret values out of your source code and app settings. Developers can run event-driven tasks on Azure while keeping keys in one store. Platform teams maintain one set of audit logs and rotation rules in Google Cloud. How azure functions and gcp secret manager share identity and data Connecting two cloud providers used to require static ser

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.

Teams use azure functions and gcp secret manager to run code across clouds. The function app reads keys from Google Cloud at run time. This workflow keeps secret values out of your source code and app settings. Developers can run event-driven tasks on Azure while keeping keys in one store. Platform teams maintain one set of audit logs and rotation rules in Google Cloud.

How azure functions and gcp secret manager share identity and data

Connecting two cloud providers used to require static service account keys. Static keys create huge risks if someone leaks them in a code repo. Modern cloud teams use workload identity federation instead of exported JSON files. First, you give your Azure function app a managed identity in Entra ID. This identity acts as the unique badge for that specific function app.

Next, you set up a workload identity pool inside your Google Cloud project. You link this pool to your Azure tenant and app registration details. When the function runs, it asks Azure for an identity token. The function sends this token to the Google security token service. Google checks the token and returns a short-lived Google credential.

Finally, the function uses that temporary credential to call the secret store. It asks for the exact secret version it needs for the task. The secret value travels over an encrypted link straight into the function memory. The app uses the key in memory and writes nothing to disk.

Common failure modes and how to scope roles

Many teams make mistakes when they first set up cross-cloud secret reads. The biggest mistake is sharing one identity across ten different function apps. If one app gets hacked, the attacker can read every single secret. Give each function app its own user-assigned or system-assigned identity instead. Map each Azure identity to a distinct principal in Google Cloud.

Overly broad IAM roles are another common problem in multi-cloud setups. Never grant project-wide secret reader roles to a single serverless function. Bind the read permission directly to the one secret the app needs. If an app only needs a payment API key, block everything else. Pin your reads to a known secret version when you want stable deploys.

GCP Secret Manager + Azure RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Rate limits and cold starts can also break your production workloads. If a function fetches secrets on every run, costs and latency go up. Cache the secret value in memory for the life of the worker instance. Refresh the cached value only when a key rotation happens. Turn on data read audit logs in Google Cloud to track every call.

Handling rotation and network boundaries

Secret rotation often breaks live apps when teams forget about active memory caches. When Google Cloud rotates a secret, it creates a brand new version. Your function app needs a clean way to pick up that new version. Set a short time-to-live on your in-memory cache inside the function code. If a database call fails with an auth error, clear the cache right away. The function will then fetch the newest secret version on the next retry.

Network paths between Azure and Google Cloud also need strict rules. By default, serverless functions call public Google API endpoints over the internet. You can lock this down by placing your function in a virtual network. Use private routing or strict outbound firewall rules to control traffic flow. Only allow outbound calls to the Google identity and secret endpoints you need.

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

How do I avoid storing Google JSON keys in Azure?

Use workload identity federation between Entra ID and Google Cloud. Your Azure managed identity gets a token and swaps it for a Google token. No static keys ever sit in your app settings.

Should Azure Functions fetch secrets on every single execution?

No, fetching secrets on every run adds latency and hits API rate limits. Store the secret in a static memory variable after the first cold start. Add a timer to refresh that value every few minutes.

How do I audit which function read a secret?

Turn on Data Access audit logs for Secret Manager in Google Cloud. Give each Azure function a unique identity so every log entry shows the caller.

The query runs. The emails stay hidden.