The Simplest Way to Make Cosmosdb and Google Pub/Sub Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair cosmosdb and google pub/sub to move database updates across clouds in real time. One system stores document records while the other broadcasts event messages to downstream apps. This workflow keeps data in sync across Azure and Google Cloud. When a user updates a record, your worker reads the change feed and sends a message. Analytics services and microservices then read that topic and react right away. How cosmosdb and google pub/sub share data and permissions Moving data between

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 pair cosmosdb and google pub/sub to move database updates across clouds in real time. One system stores document records while the other broadcasts event messages to downstream apps.

This workflow keeps data in sync across Azure and Google Cloud. When a user updates a record, your worker reads the change feed and sends a message. Analytics services and microservices then read that topic and react right away.

How cosmosdb and google pub/sub share data and permissions

Moving data between two clouds requires a small worker app in the middle. Neither service talks to the other on its own out of the box. You must run a function or container that bridges the two APIs.

First, the worker logs in to Azure using a managed identity or role. It listens to the database change feed for new or updated items. Each change contains the document fields that your downstream teams need.

Next, the worker logs in to Google Cloud to publish the event. The cleanest approach uses workload identity federation instead of static service account files. Azure issues a token, and Google Cloud trades it for a short-term access token. The worker then writes the payload to the target topic.

Good permissions keep this path safe. The Azure role only needs read rights on the specific database container. The Google Cloud role only needs publish rights on one specific topic. Neither side should hold admin rights or full project roles.

Common failure modes and how to scope roles

Cross-cloud setups often break because teams take shortcuts with keys and roles. A common mistake is pasting long-lived master keys into app settings. If a developer leaves or a repo leaks, those keys stay active for months.

CosmosDB RBAC + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Shared service accounts cause another big headache for platform teams. When five apps use one account, you cannot tell who ran a bad query. Audit logs show the shared account name instead of the real person or service. If you revoke that key to fix a leak, all five apps go down.

Unlogged database queries also create blind spots during live outages. Engineers often log in to the database directly to fix broken event payloads. Without query logs or data masking, raw emails and card numbers appear on their screens. Data masking rewrites matched fields in results so phone numbers and national IDs stay private.

To fix these risks, scope every role to the smallest task possible. Give each worker app its own distinct identity in both clouds. Block public network traffic and route cross-cloud calls through private VPN or interconnect links. Rotate secrets on a set schedule and log every read or write action.

Running day-to-day checks and fixes

Even a great pipeline will hit poison messages or schema bugs over time. When a message fails to publish, engineers need to inspect the source record fast. They also need to check topic queues without holding permanent admin rights.

Standard cloud consoles make it hard to tie a database read to a specific ticket. Teams do best when they tie every manual check to a user identity. That way, you know who read which record and when they did it.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

How do we connect the two tools without saving static JSON keys?

Use workload identity federation between Azure and Google Cloud. Your Azure app presents its native identity token to Google Cloud. Google checks the token and grants temporary publish rights without any saved key files.

What happens if the message topic rejects a database update?

Your worker app should catch the error and stop moving the change feed pointer forward. Send failed payloads to a dead-letter storage queue for review. An engineer can then inspect the bad record, fix the format, and replay the event.

How can engineers debug source data without exposing sensitive user fields?

Set up read roles that apply dynamic data masking to query results. When an engineer runs a check, the system rewrites emails and card numbers on the fly. The engineer sees the document structure and fixes the bug while private data stays safe.

The query runs. The emails stay hidden.