Azure Cloud Series: This lesson is part of our comprehensive Complete Microsoft Azure Tutorial: Learn Azure from Beginner to Advanced.

KODESTREE TECHNOLOGIES

AZURE SEO CONTENT HUB

Pillar cluster: Azure DevOps, Infrastructure as Code & Automation

Primary search intent: Understand continuous integration and continuous delivery with Azure Pipelines.

Azure Pipelines is part of Azure DevOps and automates build, test and delivery workflows for applications and infrastructure. A pipeline can run when code changes, execute repeatable validation, publish versioned artifacts and deploy an approved version to one or more environments. This reduces dependence on undocumented manual release steps and provides a consistent record of what was built and deployed.

Continuous integration (CI) focuses on integrating changes frequently and validating them with automated builds and tests. Continuous delivery (CD) prepares deployable artifacts and moves them through controlled environments. A mature process also considers code review, dependency security, secret handling, approvals, observability and rollback. A green pipeline is useful evidence, but it does not replace sound release design or production verification.

This article explains pipeline structure, YAML, triggers, stages, jobs, agents, artifacts, service connections, environment approvals, security and troubleshooting. The examples are starting points; adapt runtime versions, tasks, approvals and deployment targets to the application and current Azure DevOps capabilities.

What You Will Learn

  • Explain CI and CD and where Azure Pipelines fits.
  • Understand YAML pipelines, triggers, stages, jobs, steps and agents.
  • Separate building, testing, artifact creation and deployment.
  • Use environments, service connections and approvals deliberately.
  • Protect credentials, pipeline permissions, repositories and agents.
  • Add quality checks, deployment verification and rollback planning.
  • Troubleshoot failed runs using logs and pipeline evidence.

Quick Reference: Core Concepts

Concept Purpose
Pipeline A defined workflow that automates build, test, publish or deployment steps.
Agent The compute environment that runs pipeline jobs.
Stage A logical phase, often used for build, test or deployment progression.
Artifact A versioned output of the build, such as a package or container image.
Service connection A configured connection through which a pipeline can access an external resource.
Environment checks Approvals or controls that govern access to a deployment environment or protected resource.

1. What Is Azure Pipelines?

Azure Pipelines is a CI/CD service that can build, test and deploy applications across supported languages, platforms and targets. It works with Azure services, virtual machines, containers and other deployment environments. Pipeline definitions capture steps developers and operators would otherwise run manually, which makes the process repeatable and easier to audit.

Pipelines can be defined in YAML stored alongside code or through the Classic interface for supported workflows. YAML is commonly recommended for new pipelines because it can be reviewed and versioned like application code. Existing Classic pipelines may remain in use where appropriate, but teams should understand their support model and avoid letting release logic become disconnected from the repository.

2. Why CI/CD Matters

Without CI, defects can accumulate until a large change is integrated, making it difficult to identify which commit caused a regression. Automated builds and tests provide early feedback. CD extends that feedback into release preparation and deployment. Teams can publish a tested artifact and promote it through environments instead of rebuilding different binaries for each stage.

Automation alone does not guarantee frequent or safe releases. Tests must cover meaningful behavior, dependencies need security review, production access must be controlled, and deployment failures must be observable. A fast pipeline that skips essential validation can increase risk. Design it to deliver reliable signals and remove unnecessary waiting while preserving the controls the workload requires.

3. CI, CD and Release Terminology

Continuous integration means regularly merging changes into a shared codebase and automatically building and testing them. Continuous delivery keeps changes in a deployable state and supports release to production through a controlled decision. Continuous deployment goes further by automatically releasing changes that pass required checks. These practices represent different levels of automation and risk tolerance.

A build artifact is the package, image or other versioned output consumed by later stages. A stage groups a phase of work, a job runs on an agent and a step executes an action such as a script or task. An environment can represent a deployment target and provide a boundary for approvals, history and checks. Clear terms help teams diagnose where a pipeline stopped.

4. Pipeline Structure: Triggers, Stages and Jobs

A YAML pipeline specifies when it runs, the agent pool or environment, jobs to execute and steps within those jobs. Triggers can respond to repository updates, branches, schedules or resource events, depending on supported configuration. Stages represent meaningful gates such as build, test, package and deploy.

Keep the pipeline as simple as the workflow allows. Many conditional paths make releases difficult to reason about, while a single massive job makes failure analysis and reuse harder. Separate independent checks where parallel execution helps, and use explicit dependencies when one stage consumes another stage’s artifact. Avoid relying on hidden variables or undocumented state left behind by previous jobs.

5. Agents and Execution Environments

Agents execute pipeline jobs. Microsoft-hosted agents reduce the need to maintain the underlying machine image, while self-hosted agents offer more control over tools, network access and configuration. The right choice depends on dependencies, private network requirements, compliance and operational ownership. Self-hosted agents should be treated as infrastructure with patching, monitoring, access control and cleanup requirements.

Do not assume an agent contains every required tool version. Install or select tools explicitly, use reproducible build steps and document runtime assumptions. Limit sensitive workloads on shared agents, especially when one project’s code could influence later tasks. Avoid leaving credentials, downloaded artifacts or workspace data behind after a run.

6. YAML as Pipeline Code

YAML pipeline definitions can be reviewed through pull requests, stored near the application and reused through templates. Parameters, variables, conditions and templates can reduce duplication, but an overly generic YAML framework may be harder to understand than a clear sequence of stages. Use names that describe each job’s purpose and keep scripts short enough to review.

Syntax and evaluation rules matter: indentation, quoting, expression types and the difference between compile-time and runtime expressions can affect behavior. Validate changes in a feature branch and inspect expanded template behavior where appropriate. Protect pipeline files with the same code-review discipline as application source because pipeline edits change where code executes and which resources it can access.

7. Build, Test and Artifact Strategy

A robust pipeline checks out a known source revision, restores dependencies, builds the application, runs tests and produces a versioned artifact. Later stages should consume the artifact created by the build rather than silently compiling different source again. This creates a clear connection between a tested commit and the version deployed to an environment.

Test layers can include unit tests, integration tests, static analysis, dependency or container scans and post-deployment smoke tests. Not every project needs every check at the same depth, but important risks should have an explicit validation step. Preserve test reports and artifacts for diagnosis while applying sensible retention controls.

8. Environments and Deployment Gates

Use separate development, test, staging and production environments when release risk warrants it. Make the target visible and do not infer production solely from a branch name when stronger controls are appropriate. Environment approvals and checks can require a person or an external condition before a deployment proceeds.

Approvals should add information or deliberate authorization, not merely create a ritual click. The reviewer needs release notes, test evidence, change impact and a backout plan. Limit who can bypass checks and audit exceptions. For deployments that affect customer data, network exposure or identity permissions, require stronger review than for a low-risk documentation update.

9. Service Connections and Azure Authentication

A service connection provides a configured path for pipeline tasks to access Azure or another protected resource. Use a supported modern authentication method, prefer workload identity federation where available, and scope permissions narrowly. Service connections should not be shared broadly across unrelated projects or provide more access than the pipeline needs.

Separate connections by environment or responsibility when this improves control. A test deployment pipeline should not automatically have unrestricted production access. Protect the ability to edit connections, restrict which pipelines may use them, rotate any remaining credentials and audit changes. Prefer role assignments scoped to the resource group or resources managed by the pipeline.

10. Protecting Secrets and Variables

Pipeline variables may contain ordinary configuration, but secrets require special handling. Use secret-marked variables and approved secret stores, restrict access and avoid printing values from scripts. Masking helps but is not a guarantee against every leakage path. Avoid passing secrets through command-line arguments, artifacts or verbose logs when a safer supported method exists.

Prefer identity-based access where possible so a pipeline can obtain short-lived access without storing long-lived credentials. Restrict which jobs and stages receive secrets; untrusted pull-request code should not automatically receive production secrets. Treat templates as executable code because a modified task can attempt to exfiltrate credentials available to a job.

11. Quality, Security and Policy Checks

A pipeline can enforce standards through linting, tests, dependency checks, security scans, infrastructure validation and policy-related checks. A failed job should identify the check, the affected file or package, and a remediation path. Separate blocking conditions from informational warnings according to risk and organizational policy.

Security checks should run early enough to provide feedback before release approval. Avoid relying on a last-minute manual scan that nobody can reproduce. Give exceptions an owner and expiry so known risks do not remain permanently ignored. For infrastructure changes, validate templates and inspect What-if output before modifying shared or production resources.

12. Artifacts, Packages and Versioning

Artifacts provide the handoff between build and release. Use clear version identifiers tied to a commit, release or immutable build number. Store outputs in an approved repository and ensure later stages retrieve the exact version tested. Container workflows should tag images meaningfully and capture an immutable digest when that improves traceability.

Do not rebuild an artifact separately for each environment unless the design requires it and differences are controlled. Environment-specific configuration can often be injected during deployment. Retain artifacts long enough for rollback and compliance needs, but not indefinitely without a reason. Document which artifact was deployed when diagnosing a production issue.

13. Monitoring and Deployment Verification

A pipeline result shows whether its configured steps completed, not whether users can successfully use the application. Add post-deployment smoke tests and health checks for critical paths. For applications with dependencies, validate the request path, identity, network connectivity and key service calls. Confirm telemetry reaches the intended destination and alerts remain functional after deployment.

Capture deployment records, artifact version, environment, timestamps and test outcomes. If verification fails, decide whether to halt promotion, roll back or apply a forward fix. The correct action depends on data compatibility and whether a migration is reversible. Make this decision part of the release plan rather than improvising it during an outage.

14. Reliability, Rollback and Database Changes

Deployment reliability depends on more than pipeline YAML. Applications should tolerate the planned release strategy, health probes should reflect real readiness, and dependent services must remain compatible during rollout. Database or schema changes are often harder to reverse than application binaries; use staged, backward-compatible changes where possible.

A rollback is safe only when the previous version can work with current data and infrastructure. Some systems need a forward fix or restore procedure rather than redeployment of an older binary. Retain the prior artifact, document migration behavior and rehearse failure scenarios for high-impact services.

15. Permissions and Governance

Keep repository permissions, pipeline-edit permissions, service connection access and production approvals distinct. Someone who can change a pipeline running with elevated identity may indirectly gain that identity’s permissions. Require code review for protected branches and restrict direct changes to privileged pipeline definitions.

Use templates for common defaults such as tests, scanning, logging and deployment gates, but allow teams to understand and validate them. Minimize broad organization-level identities where a project-scoped identity works. Review audit events and clean up unused pipelines, connections, secrets and agent pools.

16. Practical Scenario: Deploying a Web Application

A basic workflow starts when code is merged to a protected branch. The pipeline restores dependencies, builds the application, runs unit tests and creates a package. A deployment stage sends that package to a test environment, runs smoke tests and publishes results. Promotion to production uses the same artifact and waits for configured approvals or checks.

If a test fails, the pipeline stops before production and makes logs and reports available. After deployment, verify the endpoint, application logs and dependencies. Document the deployed artifact and where the rollback candidate is stored. This workflow can later add infrastructure deployment, database compatibility checks or image scanning without losing the separation between build, validate and release.

17. Common Mistakes to Avoid

Common mistakes include putting secrets in YAML, granting one connection access to every environment, deploying production from unreviewed branches, using mutable artifact tags without traceability and treating a successful build as proof of application health. Self-hosted agents can also become a risk when workspaces or credentials persist between jobs.

Avoid copy-and-paste pipelines that drift across projects. Reuse small, reviewed templates and document exceptions. Do not suppress quality checks merely to achieve a green build. For emergencies, use an audited exception process with an owner and follow-up review rather than permanently weakening normal controls.

18. Troubleshooting Failed Runs

Start at the first failing task and inspect its logs and inputs. Identify whether the cause is syntax, permissions, unavailable tools, dependency restore, tests, artifact publishing, networking or deployment configuration. Verify source commit, variable values, agent environment, service connection and target environment. For deployment failures, inspect the underlying Azure deployment or service operation rather than relying only on the pipeline summary.

Rerun only after understanding whether the task is safe to repeat; a failed upload or deployment may have partially succeeded. Preserve logs and artifact identifiers, fix the source or configuration and add a test that catches the failure earlier. If an issue depends on a hosted agent image, install tools explicitly rather than relying on a temporary default.

19. Pre-production Checklist

Confirm branch protection, build reproducibility, tests, dependency and security checks, artifact versioning, service connection scope, secret access, environment approvals, post-deployment verification, monitoring and rollback guidance. Limit production deployment to reviewed commits and authorized identities. Verify that the pipeline cannot target an unintended subscription, namespace or service.

Run a failure exercise appropriate to the workload: a failed test, rejected deployment, health-check failure or denied access. Ensure the process stops promotion and surfaces enough evidence for an operator. The release runbook should identify ownership, dependencies, relevant alerts and first steps when a deployment does not behave as expected.

Frequently Asked Questions

Should I use YAML or the Classic pipeline editor?

Microsoft recommends starting with YAML for new Azure Pipelines because the definition can be versioned and reviewed with code. Existing Classic pipelines may remain suitable depending on project requirements and support constraints.

What is the difference between CI and CD?

CI regularly builds and tests integrated changes. CD prepares deployable artifacts and delivers them through controlled environments; continuous deployment automatically releases changes that pass required controls.

Does a green pipeline guarantee a successful release?

No. Configured steps may pass while production behavior still fails. Use post-deployment health checks, telemetry and a documented response plan.

How should Azure Pipelines authenticate to Azure?

Use a supported service connection and modern identity method, preferably workload identity federation where available. Scope permission to the required environment and resources.

Where should pipeline secrets be stored?

Use secret variables and approved secret stores, restrict access and avoid logging values. Prefer identity-based access where supported.

When should a production deployment require approval?

Use approvals and checks when risk, compliance or operational ownership requires an explicit decision. Protect access to bypass checks and record exceptions.

Conclusion

Azure Pipelines can make build, testing and delivery repeatable, but quality depends on release design. Keep YAML readable, build traceable artifacts, separate environments, minimize connection permissions, protect secrets and require appropriate checks for production. Use deployment verification and telemetry to confirm real behavior, and define what happens when a stage fails. The goal is a secure, traceable path from reviewed source to a healthy application.

20. Security Fundamentals

Treat pipeline definitions, repositories, agents and service connections as part of the production security boundary. Restrict who edits privileged workflows, use scoped identities, avoid secrets in logs and protect deployment environments with approvals and checks. Ensure untrusted code cannot automatically access privileged resources.

21. Additional Limitations and Operational Considerations

Hosted agent images and task versions can change, while self-hosted agents add patching and maintenance obligations. Deployment tasks may behave differently across targets. Record tool assumptions, monitor deprecations and test pipeline updates before changing a production release path.

Start with a small YAML pipeline that builds an app and runs unit tests. Publish an artifact and deploy it to test. Then add service-connection authentication, approval gates, security scanning and post-deployment checks. Learn to inspect logs and restore the last known healthy artifact before designing complex multi-stage workflows.

23. Service Selection and Architecture Thinking

Use Azure Pipelines for repeatable workflows across source, build and deployment. Select agents based on dependencies, network and compliance requirements. Keep infrastructure deployment, application packaging and release verification as clear stages while templates standardize common controls.

24. Scalability and Performance

Reduce pipeline time by caching supported dependencies, running independent tests in parallel and avoiding repeated builds of the same artifact. Use concurrency controls to avoid overwhelming shared environments. Measure optimizations and ensure they do not reuse stale or unsafe outputs.

25. Reliability and Recovery

A reliable release process records what is deployed and can halt promotion when checks fail. Plan how to roll back or repair application code and stateful changes. Retain approved artifacts, keep smoke tests meaningful and rehearse deployment-failure response for workloads where downtime or data loss matters.

26. Hands-on Practice and Production Thinking

Create a YAML pipeline that builds a small application, runs tests, publishes an artifact and deploys to a disposable test environment. Add a health check and approval before a protected environment. Deliberately break a test to confirm deployment stops and failure evidence is easy to find.

Example: CI to controlled deployment

A compact pipeline can have a build-and-test stage followed by test deployment. The build produces one versioned artifact; test deployment runs a smoke test; production consumes the same artifact and is protected by approved environment checks.

When a test or health check fails, promotion should stop and logs should remain available. If production deployment partially executes, the runbook should explain how to inspect service state before retry or rollback. The pipeline is complete only when failure behavior is as deliberate as the successful path.

Continue with these related tutorials to connect this topic to the wider Azure learning path:

  • Azure CLI, PowerShell and SDKs
  • Azure Resource Manager (ARM) Templates
  • Bicep and Infrastructure as Code on Azure
  • Azure Container Registry and Container Deployment
  • Azure DevOps Automation Best Practices

References and Further Reading

Use the following Microsoft documentation as the primary technical references. Check current command syntax, product capabilities, service limits and pricing before production use:

  • Azure Pipelines documentation
  • What is Azure Pipelines?
  • YAML vs Classic Pipelines
  • Secure your Azure Pipelines
  • Pipeline resource security
  • Deploy to Azure services with Azure Pipelines

SEO and Editorial Metadata

Document ID Azure-054
Article Title Azure Pipelines and CI/CD
Primary Search Intent Understand continuous integration and continuous delivery with Azure Pipelines
Suggested URL /azure-pipelines-ci-cd/
Canonical URL https://kodestree.com/azure-pipelines-ci-cd/
Pillar Page https://kodestree.com/azure-tutorial/
Content Cluster Azure DevOps, Infrastructure as Code & Automation
Recommended Internal Links Link contextually to the Azure pillar and adjacent Azure tutorials where the reader benefits.