The Simplest Way to Make Azure Cosmosdb and Bitbucket Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use azure cosmosdb and bitbucket to run code changes and update database settings together. Bitbucket runs the build steps, while Azure CosmosDB stores the app data for each stage. This setup lets developers test database changes before they reach live users. It also keeps schema updates, index rules, and app code in one shared place. When a developer merges a pull request, the build runner pushes the changes out. Without clear rules, this link can expose master keys and break live databa

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 cosmosdb and bitbucket to run code changes and update database settings together. Bitbucket runs the build steps, while Azure CosmosDB stores the app data for each stage.

This setup lets developers test database changes before they reach live users. It also keeps schema updates, index rules, and app code in one shared place. When a developer merges a pull request, the build runner pushes the changes out. Without clear rules, this link can expose master keys and break live databases.

How azure cosmosdb and bitbucket share roles and data

Bitbucket runs automated jobs when a developer pushes code to a branch. These jobs often need to create containers, change throughput, or load test data. To do this, the build job must log in to the cloud account.

The best way to log in is through open standards that use short tokens. Bitbucket can send a signed identity token to the cloud provider during a run. The cloud provider checks this token and grants a role for that single job. This removes the need to store static keys inside the repo settings.

Once the job logs in, it talks to the database control plane or data plane. Control plane calls set up accounts, containers, and network rules. Data plane calls read and write items inside those containers during tests.

Many teams start by pasting a primary database key into Bitbucket variables. This is a major risk because primary keys have full power over all data. Anyone who can edit the build file can print or steal that key. Shared service accounts also make it hard to see who ran a bad query.

Broad permissions cause problems when a test job points to the wrong database. A script meant for a test stage might wipe out live customer records. Unlogged queries from build runners also leave security teams blind during an audit. If a runner reads sensitive items, the team needs a clear record of that event.

Azure RBAC + CosmosDB RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Scoping roles and network paths between systems

Start by splitting control plane tasks from data plane tasks in your jobs. Give the build runner a narrow role that only touches the target stage. A test branch should only have rights to talk to the test database account. Production changes should require a review step from a senior team member.

Lock down network paths so the database does not accept calls from everywhere. Cloud runners use wide IP ranges, which makes firewall rules hard to maintain. Teams often run their own build agents inside a private cloud network instead. This keeps all database traffic off the public internet and inside private links.

Managing manual database checks after a build

Automated jobs handle most updates, but engineers still need to check data by hand. When a build fails, a developer often needs to inspect items or fix state. Handing out full account keys for these quick fixes brings back all the old risks.

Teams should tie every human query to a real user identity. Engineers should get read rights by default and ask for write rights when needed. Data masking can also rewrite emails, phone numbers, and card numbers in query results. This keeps private user details safe while developers fix bugs from failed builds.

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 should Bitbucket runners log in to Azure CosmosDB?

Use federated identity tokens instead of static master keys in your build settings. The runner trades a short token for a scoped cloud role during the job.

How do we stop build jobs from changing live data by mistake?

Create separate identities for each deployment stage in your repo settings. Map the test identity only to test databases, and lock production behind branch approvals.

What is the safest way for developers to inspect data after a failed build?

Route human queries through a central point that checks identity and logs every action. Apply data masking to rewrite card numbers and emails in the query output.

The query runs. The emails stay hidden.