AZ-400: Designing and Implementing Microsoft DevOps Solutions
Design and Implement Pipelines
Pipeline triggers
Azure Pipeline Triggers automate the start of your build and deployment workflows when specific events or conditions occur. By using triggers effectively, you can streamline code validation, testing, and delivery across your CI/CD lifecycle.
Azure Pipelines supports four primary trigger types:
Trigger Type | Description | YAML Keyword |
---|---|---|
CI | Start a build when code is pushed | trigger |
PR | Validate pull requests before merging | pr |
Scheduled | Run pipelines at defined times (nightly, weekly) | schedules |
Manual | Launch pipelines on demand via UI or CLI | N/A |
Continuous Integration (CI) Triggers
Continuous Integration (CI) triggers automatically queue a pipeline run whenever new commits are pushed to selected branches. This immediate feedback loop helps catch build failures or integration errors early.
In YAML pipelines, enable CI by defining the trigger
section:
trigger:
branches:
include:
- main
- release/*
- feature/*
trigger:
activates CI-based runsbranches.include:
lists branch patterns to watchmain
builds production coderelease/*
handles hotfix or release branchesfeature/*
catches ongoing development work
Note
Wildcards (*
) help you include entire branch families. To exclude specific branches, use exclude:
under branches
.
Scheduled Triggers
Scheduled triggers run pipelines at specified intervals or cron schedules—ideal for nightly builds, periodic tests, or routine deployments.
To disable CI and add a schedule in YAML:
trigger: none # Turn off CI-based runs
schedules:
- cron: "0 2 * * 1-5" # Weekdays at 02:00 UTC
displayName: Weekday Early-Build
branches:
include:
- main
always: true # Run even without new commits
trigger: none
ensures only scheduled runs occurcron:
follows standard cron syntax (min, hour, dom, mon, dow)always: true
runs the job regardless of changes
Note
Cron schedules in Azure Pipelines are evaluated in UTC. Adjust your cron
expression if your team operates in other time zones.
Pull Request (PR) Triggers
PR triggers automatically validate code changes when a pull request is opened or updated. This enforces quality gates before merging to protected branches.
Example YAML configuration:
pr:
branches:
include:
- main
- develop
- feature/*
paths:
exclude:
- docs/**
pr:
defines pull request validation triggersbranches.include:
lists target branches for PR checkspaths.exclude:
skips runs when only documentation changes
Manual Triggers
Manual triggers allow teams to start pipelines on demand for production rollouts, hotfix deployments, or ad hoc testing.
You can invoke a manual run via:
- Azure DevOps UI: Click Run pipeline and select parameters
- Azure CLI:
az pipelines run \
--name MyPipeline \
--branch feature/hotfix \
--variables deployEnv=staging
Warning
Manual deployments bypass automated gates. Ensure you have approvals or checks in place for sensitive environments.
Best Practices
Adopt these recommendations to keep your pipelines efficient and reliable:
- Be selective with branch filters to reduce unnecessary runs.
- Use path and tag filters to scope triggers precisely.
- Combine CI, PR, and scheduled triggers for comprehensive coverage.
- Implement manual approvals for production or compliance-sensitive deployments.
- Regularly review and clean up stale schedules or branch patterns.
References
Watch Video
Watch video content