Mountain landscape with pipelines running through a valley
Back to blog
azureazure devopscicd

Continuous Deployment with Azure DevOps

Sven HennessenDevOps

How to create reusable pipelines with Azure DevOps and YAML templates, and define and automate deployment processes across teams.

Introduction

In the dynamic world of software development, the right implementation of DevOps practices can make or break a project. Microsoft Azure DevOps offers an impressive set of tools to efficiently build Continuous Integration and Continuous Deployment (CI/CD) pipelines. In this article, we take a look at a few helpful fundamentals.

YAML Templates and Repository Resources

YAML Templates provide a reusable structure for Azure DevOps Pipelines, allowing pipeline configurations to be managed as code. In combination with Repository Resources, these templates can be defined once and then used across multiple projects. The templates live in one Git repository, while the individual projects reside in separate repositories. This ensures that all projects use consistent and up-to-date pipeline configurations.

resources:
  repositories:
    - repository: templates
      type: git
      endpoint: # Name of the service connection in Azure DevOps
      name: # Name of the repository containing the templates
      ref: # Optional, git ref in the target repository

stages:
  - template: templates/deploy-template.yml@templates
Repository Resources Flow Diagram

Automating Deployments with Pipeline Resources

Azure DevOps enables deployment automation through Build Completion Triggers, which ensure deployments are only performed when the previous build was successful. Pipeline Resources and their trigger configuration allow fine-grained control over when the current pipeline should be started automatically.

For example, a deployment can be triggered automatically as soon as the build of an application component has succeeded.

resources:
  pipelines:
    - pipeline: BuildPipeline
      source: BuildPipeline
      trigger:
        branches:
          include:
          - main

stages:
  # Deployment Stages
Pipeline Resources Sequence Diagram

Multi-Stage Pipelines

Pipelines represent multi-stage processes, where stages can represent — for example — the build of a specific application component or a deployment to a defined system. The dependsOn attribute allows complex dependencies between different stages of a pipeline to be expressed, enabling precise control over the deployment flow across different environments.

stages:
  - stage: deploy_to_staging
    jobs:
      - job: ...
  - stage: deploy_to_environment_a
    # Only runs when "staging" has been deployed successfully
    dependsOn: deploy_to_staging
    condition: succeeded()
    jobs:
      - job: ...
  - stage: deploy_to_environment_a
    dependsOn: deploy_to_staging
    condition: succeeded()
    jobs:
      - job: ...
Multi-Stage Deployment Flow Diagram

Summary and Outlook

Azure DevOps offers a wide range of features to design modern software development processes efficiently and securely. The features shown here form the foundation for a sustainable design of automated CI/CD pipelines.

But there is much more that Azure DevOps Pipelines can do. In the next articles on this topic, we will look at how deployments can be secured through approvals, how to handle secrets ideally, and how pipelines can be used to automate deployments to Kubernetes with Helm.

Need support?

Want to introduce or optimise CI/CD pipelines with Azure DevOps in your organisation but unsure about implementation? We're happy to help! Just get in touch and we'll work together to automate your deployment processes.

Get in touch