CI/CD Best Practices for Azure Devops

Hardik Shah
5 min readJul 1, 2022

CI/CD is one of the most important parts of modern application development. We want to make sure that we can test our applications before they get deployed, and we want to be able to quickly deploy our code once it’s ready. This guide will help you with best practices for CI/CD in Azure DevOps so you can start deploying your own applications today!

Deploy at any time.

Deployment should be easy to schedule at any time, easy to roll back, easy to monitor and automate.

  • Deployment should be as simple as possible

The goal here is to make it easy for developers to start deploying code without needing them to learn about CI/CD first. You want your developers able deploy the code they wrote because they have confidence that the deployment will succeed. They shouldn’t need an automated build pipeline or a separate engineering team just so they can get their work out there; they should only need themselves and maybe some documentation on how you do things around here!

  • Deployment should be scheduled at any time

It’s nice when deployments can happen with little intervention from humans — after all, we’re not robots in human suits yet (Ctrl+C / Ctrl+V). But there are times when manual intervention is required: rolling back changes after an error was detected or verifying that new features work well before deploying them live for everyone else.

Automate your tests.

Automating your tests is a great way to catch bugs, regressions, performance issues and security issues.

It’s also easy to do — if you follow this process:

  • Choose the testing framework that suits your needs (there are many) and learn how it works.
  • Write some tests using the chosen framework.
  • Run those tests in Docker containers on every build of your software.

Deploy in small increments.

You do not have to deploy your application in one big chunk. You can deploy in small increments and test it before deploying the next increment. This will make it easier for you to troubleshoot and debug because there would be less code changes between each increment and you would know exactly what caused the problem when something goes wrong.

If you are deploying an application in multiple versions, then small increments also allow you to rollback easily if any of the versions does not work as expected or has a bug which needs fixing before the next version is deployed. It allows you to scale more easily as well since scaling up is easier than scaling down.

Define your deployment branches carefully.

Branches are a great way to isolate changes and ensure they don’t affect other parts of the application. They allow teams to work in parallel without interfering with each other or breaking the master branch.

In Azure DevOps, you can create branches out of any commit or pull request (PR). Each branch should have its own workflow, so you can choose what happens during each step in your CD pipeline — for example:

  • Isolate new features from existing ones. This is especially important if you’re using containers; otherwise, it’s easy for containers built by one team to collide with containers built by another team on the same host machine.
  • Build multiple versions of your app at once (i.e., test versus production), so that you know exactly which version is being deployed where at all times.
  • Deploy code into different environments (QA vs staging vs production) based on criteria such as environment variables or feature flags set in code; this also helps avoid conflicts between environments if two releases happen simultaneously through branching/merging strategies like feature flags or rollbacks scripts.

Track your changes carefully.

To ensure the quality of your CI/CD pipeline, you’ll need to track your changes carefully. To do this, you’ll want to use a process that allows you to understand what’s changed in any given build and how it relates to previous builds. The simplest way we’ve found is by using Git tags.

Use a naming convention that’s easy for humans (and machines) to understand. Don’t rely on just one tag type; use multiple types so that each level of change can be tracked independently!

Call home as soon as your deployment is done.

Call home is a best practice for CI/CD in Azure DevOps. It means integrating with a monitoring service that sends you alerts when your deployments fail or succeed. The benefits are:

  • You get faster feedback on whether your code has been deployed successfully or not.
  • If something goes wrong, you can quickly fix it without having to manually investigate and troubleshoot what went wrong.

There are several ways to implement call home:

  • Add a webhook in your repository that calls an HTTP endpoint when the deployment finishes successfully; or 2) Add functionality in your build pipeline to send notifications using webhooks (Azure Pipelines only).
  • Use any 3rd party tool like Pingdom (free), Rollbar ($29/month), VictorOps ($199/month), PagerDuty ($150/month), etc., all of which provide free plans for small teams

Run a full deployment on every branch pull request.

By running a full deployment on every branch pull request, you ensure that you have tested your changes and that they are ready to be merged into master. To set up this practice in Azure Devops:

  • Go to Azure DevOps
  • From the app bar, navigate to Settings > CI/CD Pipelines > Triggers and click +New trigger…
  • Select Pipeline > On a commit by default pipeline where it says “Select one or more stages”, select the stage(s) where you want this new trigger applied. The stage name appears at the top of the trigger list if there are multiple stages in your pipeline; otherwise only one stage will appear in the list with ‘All’ selected next to it. For example, if you want an additional CI/CD job triggered when any commit happens upstream of your current stage (e.g., build), then select all three stages — Build (1), Test Lab (2), Publish App Package (3).

CI/CD is an important part of modern application development

CI/CD can be a powerful tool for modern application development, and it’s important to understand what CI/CD is and how it can help your team build better software faster. CI/CD is a set of practices and tools that help you build, test, and deploy applications. It enables you to automate the process of software development by making changes in code or configuration part of an automated workflow.

With these best practices in place, you’ll have a streamlined process that minimizes human error while maximizing efficiency.

Conclusion

If you’re looking for a more in-depth look at CI/CD, we recommend checking out the free Azure DevOps eBook. The book includes everything from an introduction to what CI/CD is and how it works, through tips on optimizing your deployment process and troubleshooting problems when they arise. It even includes some sample templates that will help get you started on creating your own infrastructure with minimal effort!

--

--