Ordering Dependency Deployments Reliably
This lesson explains how to model a safe sequence, and how to reduce the need for one.
Learning outcomes
After completing this lesson, you will be able to:
- Identify a safe deployment order.
- Express order in a pipeline.
- Verify health between stages.
- Explain techniques that reduce ordering constraints.
Why order matters
Most systems have dependencies. A web front end calls an API, the API reads a database, and all of them rely on networks and identities that must already exist. If an application version that needs a new column is deployed before the column exists, requests fail. Pipelines must therefore express these relationships, instead of relying on someone remembering them.
A common sequence is foundational infrastructure first, then data, then back-end services, then front ends.
| Order | Layer | Examples |
|---|---|---|
| 1 | Shared infrastructure | Virtual networks, key vaults, identities |
| 2 | Data | Database schema changes |
| 3 | Back-end services | APIs and workers |
| 4 | Front ends | Web applications |
| 5 | Traffic | Routing changes and feature flags |
A safe release sequence
Expressing order in a pipeline
Stages and jobs with explicit dependencies make the sequence reliable. The following example ensures that infrastructure comes first, and that the API and web tier deploy only after the database succeeds.
stages:
- stage: Infrastructure
- stage: Database
dependsOn: Infrastructure
- stage: Api
dependsOn: Database
- stage: Web
dependsOn: Api
- stage: EnableFeature
dependsOn:
- Api
- WebWithin an ARM or Bicep deployment, a similar idea applies. Resource Manager works out the order from references between resources, and it deploys unrelated resources in parallel. A symbolic reference in Bicep creates an implicit dependency, and dependsOn is needed only when there is no such reference. For multiple repositories, a pipeline resource trigger or workflow_run event can start a downstream pipeline after an upstream one finishes.
The following diagram compares parallel stages with a dependency.

Order in pipelines and templates
Verifying between steps
A finished deployment task does not prove that a service works: the process may have started and then failed. Each dependent stage should wait for evidence of health. Common approaches are a smoke test that calls a health endpoint with retries, a readiness check in Kubernetes, and a check such as Invoke REST API on the following environment.
- script: |
for i in {1..20}; do
status=$(curl -s -o /dev/null -w "%{http_code}" https://api.contoso.com/healthz)
if [ "$status" = "200" ]; then exit 0; fi
sleep 15
done
exit 1
displayName: Wait for the API to report healthyReducing the need for strict order
Strict ordering creates fragile releases, and it couples teams. The better long-term approach is to make each component tolerant of neighbouring versions.
- Backward-compatible changes mean that a new API still serves old clients, for example by adding fields instead of renaming them.
- API versioning lets old and new contracts run together.
- Expand and contract makes schema changes in compatible steps, as the database lesson explains.
- Feature flags let code be deployed in any order, with the behaviour enabled when everything is ready.
- Consumer-driven contract tests verify that a service still meets what its consumers expect.
If components can be deployed independently in any order, then each team can release on its own schedule, and that is a major goal of service-oriented design.
Techniques that loosen ordering
A race between stages
An application and its database migration deploy in parallel stages. Users occasionally see errors for two minutes after each release, because the new code runs before the migration finishes. What is the most complete fix?
The application stage should depend on the database stage, and the migration should be backward compatible so that the old application continues to work while it runs. Making the order explicit removes the race. A wait step would be unreliable, because migration time varies. Retrying failed user requests would hide the symptom, and would not correct the order.
Why is a successful deployment task not proof that a service works?
Show answer
The process may start and then fail. A smoke test or readiness check gives real evidence.
Exam Tips
Remember for the exam
- A typical order is infrastructure, data, back-end services, front ends, then traffic.
- Use dependsOn or needs instead of timing assumptions.
- A finished task does not prove health; run a smoke test.
- Backward compatibility and flags reduce ordering constraints.
- Bicep infers dependencies from symbolic references.