Designing pipelines: tools, agents, triggers and YAML
GitHub Actions or Azure Pipelines, runner and agent infrastructure, GitHub repositories in Azure Pipelines, triggers, YAML structure and job order.
In this lesson you'll learn
- Choosing GitHub Actions or Azure Pipelines
- Hosted and self-hosted runners and agents: cost, tools, licences, connectivity
- Integrating GitHub repositories with Azure Pipelines
- Triggers, stages, jobs, parallelism and conditions
1. Choosing the automation tool
Both run YAML pipelines, both deploy to Azure, both support OpenID Connect. Pick by where the code and people are:
- GitHub Actions: code in GitHub, a huge marketplace of actions, workflows in
.github/workflows. - Azure Pipelines: strong for complex multi-stage releases, environments with checks, classic release history, Azure Repos or GitHub sources, and organisations standardised on Azure DevOps.
Mixing is common: code and pull request checks in GitHub, releases in Azure Pipelines, using the Azure Pipelines GitHub App to connect a GitHub repository (it reports status checks back to the pull request).
2. Runners and agents
| Option | Strengths | Watch out for |
|---|---|---|
| Microsoft-hosted agent / GitHub-hosted runner | No maintenance, clean VM each job, common tools installed | Can't reach private networks; limited minutes and parallel jobs; no state between jobs |
| Self-hosted agent or runner | Your tools, private network access, caches persist, no per-minute charge | You patch, secure and scale it; risky with untrusted pull requests |
| Managed DevOps Pools / scale set agents | Azure scales agents for you, inside your virtual network | You pay for the VMs |
| GitHub larger runners | More CPU and RAM, static IPs, private networking options | Per-minute cost |
Azure Pipelines charges by parallel jobs: one Microsoft-hosted job is free (with a monthly minute limit) for private projects; more need buying. Self-hosted parallel jobs have their own allowance. GitHub Actions includes monthly minutes by plan; Linux minutes cost least.
3. Triggers
- CI trigger:
trigger:with branch and path filters, so docs changes don't build. - Pull request trigger:
pr:(for GitHub; Azure Repos uses build validation branch policies). - Scheduled:
schedules:with cron, optionallyalways: trueto run with no changes. - Pipeline completion:
resources: pipelines:with atrigger, so a release pipeline runs when a build pipeline finishes. - GitHub Actions:
on: push,pull_request,schedule,workflow_dispatch(manual),workflow_run.
4. YAML structure and job order
A pipeline has stages, a stage has jobs, a job has steps (tasks or scripts). Jobs run on agents; steps in a job share the agent.
- Order: stages run in sequence by default;
dependsOnchanges that.dependsOn: []makes a stage run in parallel. - Conditions:
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')). - Parallelism: a
strategy: matrixruns one job for each combination (OS, version);parallel: Nsplits work such as tests. - Passing data: output variables between jobs, and pipeline artifacts between stages.
Complex scenarios include hybrid pipelines (cloud and on-premises targets via self-hosted agents), VM templates (images built with Packer or Azure VM Image Builder) and container jobs.
Example
Larkfield Group's build stage uses Microsoft-hosted agents with a matrix for Windows and Linux. The deploy stage targets an internal API, so it runs on a Managed DevOps Pool inside the company's virtual network. A path filter skips builds for changes to /docs.
Exam traps to remember
- Hosted agents can't reach private networks: use self-hosted agents or Managed DevOps Pools.
dependsOn: []removes the default dependency so a stage runs in parallel.- Path filters stop unrelated changes from triggering builds.
Test yourself: 3 check questions and exam-style practice questions on this topic are in the AZ-400 DevOps Engineer app.
Practise in the app