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

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use azure resource manager and bitbucket to deploy cloud apps from code. Bitbucket stores the templates, and Azure builds the cloud parts from those files. This workflow turns manual cloud tasks into repeatable code changes. Developers push updates to a branch, and the pipeline runs the deployment. Every change goes through a peer review before it touches your live cloud. How azure resource manager and bitbucket share roles and data The link between azure resource manager and bitbucket

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 resource manager and bitbucket to deploy cloud apps from code. Bitbucket stores the templates, and Azure builds the cloud parts from those files.

This workflow turns manual cloud tasks into repeatable code changes. Developers push updates to a branch, and the pipeline runs the deployment. Every change goes through a peer review before it touches your live cloud.

How azure resource manager and bitbucket share roles and data

The link between azure resource manager and bitbucket starts with a trust check. Bitbucket needs permission to call the Azure API and change cloud resources. In the past, teams pasted long-lived client secrets into repo settings. Today, OpenID Connect lets Bitbucket trade a short-lived token with Azure Active Directory.

When a pipeline starts, Bitbucket creates a signed identity token for that job. Azure checks the token against a trust rule on an app registration. If the branch and repo match the rule, Azure grants an access token. The pipeline runner then sends template files to the Azure management endpoint.

Azure reads the template and compares it to the current resource group state. It adds, updates, or deletes cloud parts to match the code in Bitbucket. Status messages flow back to the build log so developers see the result.

Common failure modes and how to scope roles

Many teams fail by giving one shared service account owner rights across Azure. If a bad script runs in a test branch, it can delete production data. Broad tokens also stay valid for months and sit in plain build variables. Anyone with admin rights on the repo might misuse those broad cloud permissions.

Unlogged manual queries and ad-hoc script runs create another big blind spot. When a build fails, an engineer often logs in from a laptop to fix it. Those manual fixes bypass the git history and leave the cloud out of sync. Standard activity logs show that a shared account made a change, not which person.

Azure RBAC + GCP Access Context Manager: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix this, create separate service principals for each repo and branch stage. Scope each role to one resource group instead of the whole subscription. Give the pull request runner read-only rights so it can only preview changes. Grant write permissions only to the main branch runner after a peer review.

Lock down network paths between your build runners and private cloud endpoints too. Public runners work for basic apps, but private networks need stricter rules. Run self-hosted runners inside a virtual network or allow only specific runner IP ranges.

Keeping templates and live cloud state in sync

Drift happens when engineers change settings in the web portal instead of git. The next time Bitbucket runs a deploy, it might overwrite those manual edits. Worse, the deployment might fail because a resource lock or setting changed.

Run a preview check on every pull request before merging code to main. Azure can calculate what will change and print the diff in the build log. Reviewers check this output to make sure no database or network gets dropped. Pair this check with branch restrictions so only approved code reaches your cloud.

Keep sensitive values out of your template files in the git repo. Store API keys, phone numbers, or emails in a dedicated cloud vault instead. Reference those vault items during the deploy so raw values stay out of logs.

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 should Bitbucket log in to Azure without static secrets?

Use OpenID Connect to link your Bitbucket workspace with an Azure identity. Azure checks the pipeline token and grants access for that single build run.

How do we stop a test branch from changing production resources?

Map separate Azure identities to your test and production deployment stages in Bitbucket. Scope the production identity role to the production resource group and main branch.

Why do manual portal changes break Bitbucket pipeline deployments?

Manual edits create drift between your live cloud state and your git templates. Lock down portal write rights so all changes flow through reviewed pull requests.

The query runs. The emails stay hidden.