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

Published
Length
3 min read

Luis Felipe Dias

All posts

Pairing azure cosmosdb and google pub/sub lets teams stream database changes across clouds in real time. A worker app reads updates from the database and sends messages to the queue. This setup bridges two major cloud providers for analytics and event routing. Your apps can write fast to one cloud and trigger tasks in another. Getting the link right requires clean identity rules, tight network paths, and clear logs. How data flows between azure cosmosdb and google pub/sub First, an app write

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.

Pairing azure cosmosdb and google pub/sub lets teams stream database changes across clouds in real time. A worker app reads updates from the database and sends messages to the queue.

This setup bridges two major cloud providers for analytics and event routing. Your apps can write fast to one cloud and trigger tasks in another. Getting the link right requires clean identity rules, tight network paths, and clear logs.

How data flows between azure cosmosdb and google pub/sub

First, an app writes or updates an item inside the Azure database. The database records each update in an ordered change feed log. A small worker app reads that change feed to spot new items. Then, the worker sends those items as messages to the Google topic.

Downstream services read the messages from the topic and run their jobs. To make this work, the worker app needs permissions in both clouds. In Azure, the worker uses a managed identity or a read-only key. That role only needs permission to read the database change feed.

In Google Cloud, the worker needs a role that can publish messages. Teams often use workload identity federation so the worker avoids static keys. The Azure identity trades its token for a short-term Google token. With both roles in place, data moves safely from the database to the topic.

Common failure modes and how to scope roles

Cross-cloud setups often fail when teams use shared service accounts or broad keys. A master database key gives a worker too much power to delete data. If that key leaks, an attacker can wipe out your tables. Instead, grant the worker a read-only role scoped to one container.

On the Google side, avoid project-wide editor roles for the publisher app. Scope the publisher role to the exact topic that needs the events. Another common issue comes from developers checking live data during an outage. Engineers often share admin keys to query the database or inspect messages.

Azure RBAC + CosmosDB RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Shared keys make it impossible to see who ran a query. You lose the audit trail when five people use one service account. Unlogged queries also expose sensitive fields like emails, phone numbers, and card numbers. Data masking rules can rewrite matched fields in query results to protect privacy.

Network paths between the two clouds also need tight controls. Lock down the database firewall so only known worker addresses can reach it. Use private endpoints where possible to keep traffic off the public internet. Also, make sure your worker tracks its place in the change feed. If the network drops, the worker should resume without sending duplicate messages.

Keeping operations clean during debugging

Even a well-built pipeline needs human checks when a poison message appears. A bad record in the database might break the downstream consumer app. Engineers then need to read the raw item in the database container. They also need to inspect the topic subscription to clear the stuck event.

Give engineers individual roles instead of letting them borrow the worker key. Every human check should link back to a real user identity. Log every read action so security teams can review who saw what data. When teams separate app roles from human roles, cross-cloud pipelines stay safe.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

How do we avoid storing static keys between Azure and Google Cloud?

Use workload identity federation between the two cloud providers. Your Azure worker can exchange its local identity token for a short-lived Google token.

What database permissions does the change feed worker need?

The worker only needs read permissions on the specific database container and lease container. Never give the worker write or admin permissions on the main data store.

How can we protect sensitive data moving to the message topic?

Strip or mask fields like emails, card numbers, and national IDs before publishing. You can also apply masking when engineers query the database during debugging.

The query runs. The emails stay hidden.