Azure DevOps Part 2: Repos, Branching Strategies, and YAML Pipelines
· azure-devops-series, Azure Repos, Git, YAML, Azure Pipelines
Azure DevOps series
All six parts of the series, in order:
- Part 1: Core Services & Architecture
- Part 2: Repos, Branching & YAML Pipelines (you are here)
- Part 3: Agents, Variables, Secrets & Service Connections
- Part 4: CI/CD, Build, Artifacts & Release
- Part 5: Multi-Stage Pipelines, Security & Troubleshooting
- Part 6: End-to-End Workflow, Best Practices & Interview Prep
Part 1 covered the five Azure DevOps services and the organization hierarchy. Part 2 is where that structure constrains daily work: how Git branches are named and protected, how a change becomes a pull request, and how a YAML pipeline expresses CI and CD as code. The short video above walks that path. This article follows the same order, then adds the design choices a solutions architect has to settle before a team treats main as production-ready.
Azure Repos: a branching model you can actually protect
Azure Repos is Git hosting in the cloud, with unlimited private repositories in a project. The video uses a classic set of branches: main for stable code, develop for integration, feature/* for new work, release/* to prepare a version, and hotfix/* for urgent fixes. That GitFlow-style map is a solid teaching tool. It is not the only model that works, and it is not always the one I recommend.

A GitFlow-style map: main stays stable, develop integrates, feature/* takes new work, release/* prepares a version, and hotfix/* handles urgent fixes.
The important design question is not "do we have five branch types?" It is "which branches are long-lived, and which policies protect them?" Every long-lived branch is a policy surface, a CI trigger, and a place where history can diverge. I default most product teams to a simpler trunk-based style: main is always releasable, short-lived feature branches open pull requests into main, and a release is a tag or a short-lived release/* branch only when you must stabilize a version while main keeps moving. develop earns its keep when you truly have a separate integration line, such as a scheduled release train. If every feature already merges to main after CI, develop is often a second "almost main" that nobody wants to keep green.
hotfix/* is useful when production and main can diverge, which happens the moment you support an older release. If you only ever ship from the tip of main, a hotfix is just a short feature branch with a faster review. Prefixes such as feature/, release/, and hotfix/ work well with folder-style wildcards in branch policies. A repository also needs an owner, a default branch (almost always main), and a force-push and deletion policy on that branch. Those are repo settings, not informal habits.
From commit to merge: make the pull request the only door
The video's path is the one I want every production repo to enforce: commit, pull request, review and discuss, approve, then merge into main. A commit is a snapshot with an ID, an author, a date, and a message. A pull request says the branch is ready. Review is where design and risk get discussed. Approval is a recorded decision. Merge is the only way history enters the protected branch.

The change-control path: a commit becomes a pull request, reviewers discuss and approve, and only then does the work merge into main.
If engineers can push straight to main, the rest of this article is decoration. The fix is a branch policy that requires a pull request and denies direct pushes.
A few practical rules belong next to that flow. Keep feature branches short-lived; the longer they live, the worse the merge and the weaker the review. Require a useful commit message or PR description — that text is the audit trail. Do not allow self-merge on main except for a documented emergency path. And attach the work item, so Boards stays the system of record.
Branch policies: this is what "protect main" actually means
The video lists four checks under protect main: require a pull request, a minimum number of reviewers, linked work items, and a build that must pass. That list matches the branch policies you configure on a branch or a folder prefix in Azure Repos.

Protect main with policy, not etiquette: a pull request, a minimum number of reviewers, a linked work item, and a build that must pass.
Require a pull request is the foundation. Minimum reviewers should be at least one other human; two is common when the blast radius is high. I usually disallow the author from approving their own changes on main, and I reset votes when the source branch updates, so an approval cannot outlive a late push. Automatically included reviewers keep the right owners in the loop without relying on memory.
Linked work items close the planning loop from Part 1. If you skip this, you will spend the next audit reconstructing why a change shipped. A narrow exception is fine for a documented bot that only bumps a changelog.
Build validation is the CI gate. In Azure Repos Git, pull-request validation is a branch policy, not a pr: block in YAML. The pr: trigger applies to GitHub and Bitbucket Cloud. For Azure Repos, you add a build validation policy that runs a pipeline against the merge commit of the PR, and you mark it required. I also recommend a comment-resolution policy once a team is large enough that conversations get lost.
Bypass is itself a design decision. If a small set of administrators may bypass policies during an incident, log it, limit who can do it, and review bypasses after the fact. An unprotected bypass group is just an unlocked main with extra steps. Apply the same policy set to release/* and, if you use it, develop. Feature branches can stay policy-light, with the gate at the merge into the long-lived line.
Merge strategies: history is a product decision
Once the policies pass, someone still has to choose how the PR lands. The video groups the idea into three familiar options: a merge commit that keeps the full history, a squash that produces one clean commit, and a rebase that yields a linear history. The current product is a little more specific: Merge (no fast-forward) always creates a merge commit, Squash commit flattens the PR into one commit on the target, Rebase and fast-forward replays the PR commits onto the tip and fast-forwards, and Semi-linear merge rebases first and then creates a merge commit.

Pick a default merge type on purpose. Merge commits preserve branch context; squash keeps main readable; rebase keeps history linear.
This is not a taste argument. It affects git bisect, revert, and how you read main six months later. I usually recommend squash for feature work on a busy trunk: main stays readable, and each PR is one logical change. Merge commits are better when you want to preserve that a set of commits shipped together, such as a release branch coming back to main. Rebase-and-fast-forward keeps history linear without a merge bubble, but it rewrites the PR commits, which can surprise people still working on the same branch.
The architectural move is to limit merge types with a branch policy so every PR does not invent its own history style. Pick a default for main, document any exception, and disable the types you do not want.
Azure Pipelines: CI, the artifact, then CD
With a protected main, the next question is what happens on every push and every successful build. The video describes Azure Pipelines as a three-step path: CI builds and tests on every push, an artifact is the build output, and CD deploys that artifact through environments — dev, QA, UAT, then production — with approvals along the way.

Build once, deploy the same artifact through dev, QA, UAT, and production, with approvals before the later environments.
That "build once, deploy many times" rule is the one I defend most strongly. If QA is built from one commit and production is rebuilt from the same commit later, you do not have the same bits — you have a similar-looking second compile. Publish a pipeline artifact from the CI job (or a package, covered further in Part 4), and have every CD stage consume it.
Environments in Azure Pipelines are first-class objects, not just names in YAML. They carry permissions, approvals and checks, and a deployment history. I use a real environment for anything past the first sandbox, and I put production approvals on the environment so a pipeline cannot skip them by omitting a step.
Trigger design belongs next to the branch model. A YAML trigger on main (and on release/* if you use them) is the usual CI path after a merge. Pull request validation, as noted above, is a branch policy for Azure Repos. The PR validation build should be the quality gate the team is willing to ship with. Path filters help in a monorepo so a docs-only change does not rebuild the world; they also hide broken packages if you filter too aggressively, so review them when the repo layout changes.
Part 4 of this series goes deeper on artifacts and release. The design rule here is enough to get the YAML shape right: CI produces the artifact, CD promotes it, and production is an environment with a human or an automated gate in front of it.
Classic vs YAML: put the pipeline in the repo
Azure Pipelines still offers two definition styles. Classic is a visual editor in the portal. YAML is a file in the repo, typically azure-pipelines.yml. The video is blunt, and Microsoft is too: YAML is recommended because it is code in your repo — version controlled, reviewable, and reusable through templates.

Classic is a visual editor. YAML lives in the repo, so a pipeline change is reviewed like any other change. Microsoft recommends YAML.
Classic is not broken, and a large estate may still have release pipelines that will take a quarter to migrate. I do not stall a delivery program to rewrite every Classic definition on day one. I do refuse to add new production pipelines in Classic unless there is a temporary, written exception. A YAML change goes through the same branch policies you just put on main. A Classic change is a portal edit with a weaker audit trail.
YAML also unlocks templates: a shared build.yml in a central repository, consumed with extends or a template reference, so every product does not invent its own "run tests" stage. That is how a platform team scales a standard, and how you later enforce a required template check on production.
The shape of azure-pipelines.yml
The video closes on a compact file that is still the right skeleton. A trigger decides when the pipeline runs. A pool picks the machine. Stages are the big phases. Each job runs on one agent. Steps run a task or a script.

The skeleton you will see in almost every pipeline: trigger, pool, stages, jobs, and steps. Each job runs on one agent.
A current, valid starting point looks like this, following the YAML schema:
trigger:
- main
pool:
vmImage: ubuntu-latest
stages:
- stage: Build
jobs:
- job: BuildJob
steps:
- script: dotnet build
displayName: Build the project
trigger: - main means a CI run after a commit lands on main. pool.vmImage selects a Microsoft-hosted agent image. ubuntu-latest currently maps to Ubuntu 24.04; windows-latest and macOS-latest also float (macOS-latest is currently macOS 26). If a toolchain must stay pinned, use a specific image such as ubuntu-24.04 rather than the -latest alias. Part 3 covers pools, self-hosted agents, and demands in more depth.
Stages are optional in a simple pipeline — a file with just jobs or even just steps is valid — but once you have a build phase and a deployment phase, stages make the approval boundary obvious. Each job runs on one agent. Jobs in the same stage can run in parallel unless you declare a dependency. Steps are tasks or a script / bash / pwsh step.
Two syntax rules from the video are not optional. YAML is case-sensitive: Stage is not stage, and vmimage is not vmImage. Indentation matters, and Azure Pipelines examples use two spaces per level. A stray tab, or a job indented as a step, produces errors that look mysterious until you inspect the whitespace.
A slightly more realistic CI job still fits this skeleton: build, test, then publish an artifact. Keep secrets out of this file — that is the opening brief for Part 3 — and keep environment and service connection names consistent so templates can reuse them.
trigger:
branches:
include:
- main
- release/*
pool:
vmImage: ubuntu-24.04
stages:
- stage: Build
jobs:
- job: BuildJob
steps:
- script: dotnet build --configuration Release
displayName: Build the project
- script: dotnet test --configuration Release --no-build
displayName: Run tests
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifact: drop
Once the YAML is in the repo, you can create the pipeline with the Azure DevOps CLI:
az pipelines create \
--name WebApp-CI \
--repository WebApp \
--branch main \
--yml-path azure-pipelines.yml
Design pitfalls I see on this layer
- Leaving
main(or the default branch) without a required pull request and a required build. Policy, not a team agreement, is the control. - Putting
pr:in a YAML file that lives in Azure Repos and wondering why PR builds never run. Use branch-policy build validation. - Letting every developer pick a merge type, so
mainis a mix of squashes and merge bubbles that no one can read. - Rebuilding the product in the production stage instead of deploying the CI artifact.
- Starting every new pipeline in Classic because the wizard is faster, then discovering you cannot review a pipeline change in a PR.
- Using
-latestagent images for a regulated toolchain, then spending a week after Microsoft rolls the alias. - Filtering CI paths so narrowly that a shared library can break consumers without running their tests.
- Skipping linked work items and then failing an audit you could have passed automatically.
Get the branch model, the policies, and the YAML skeleton right, and Parts 3 and 4 have a clean place to attach agents, secrets, artifacts, and release checks.
Previous: Part 1: Core Services & Architecture · Next: Part 3: Agents, Variables, Secrets & Service Connections
If you want more short, practical lessons like this on AI, code, cloud, and security, follow @rankcore.ai.
Want to go deeper?
Our step-by-step video courses turn these ideas into results.
Comments
No comments yet — be the first.