Hiral Patel

Hiral Patel

VP of Technology at Prioxis | Cloud Evangelist

LinkedIn

Automating repetitive tasks like building, testing, and deploying applications is one of the most effective ways to improve developer productivity and minimize manual errors. This is where Continuous Integration and Continuous Delivery become essential.

In modern development workflows, tools like Git and Docker help package applications with their dependencies and ensure consistent performance across environments. When combined with a platform like Azure DevOps, they enable teams to deploy quickly, maintain stability, and manage multiple environments such as development, staging, and production with ease.

This guide will walk you through the process of setting up a CI/CD pipeline for your Node.js application using Azure DevOps. By the end, you will have a working pipeline that automatically builds, tests, and deploys your Node.js app to Azure App Service every time you commit changes to your Git repository.

Build Smarter Pipelines with Prioxis

We help product teams and enterprises set up scalable, production-grade CI/CD pipelines using tools like Azure DevOps, Docker, Git, and more. Whether you are modernizing an existing workflow or building from scratch, our experts can guide or implement the right solution for your stack.

Schedule a Free CI/CD Strategy Call

Prerequisites 

Before starting, ensure you have the following: 

Azure DevOps account: If you don't have one, create an account at [Azure DevOps](https://dev.azure.com). 

Azure Subscription: You can sign up for a free Azure account if you don't have one. 

Node.js: Install Node.js from the official [Node.js website](https://nodejs.org). 

Git: Ensure Git is installed and configured. 

Visual Studio Code: Install VS Code, and optionally install the Azure App Service extension. 

Step 1: Set Up Your Node.js Project and Initialize Git 

First, we’ll create a basic Node.js application using Express.js and initialize a Git repository for version control. 

1. Create a New Node.js App 

mkdir node-cicd-app 
cd node-cicd-app 
npm init -y 
npm install express --save 

2. Set Up Express Create an `app.js` file with the following content: 

const express = require('express'); 
const app = express(); 
app.get('/', (req, res) => { 
res.send('Hello from CI/CD Pipeline!'); 
}); 
app.listen(3000, () =>console.log('App listening on port 3000'); 
}); 

3. Initialize Git 

git init 
git add . 
git commit -m "Initial commit" 

Step 2: Set Up an Azure DevOps Project 

Now, let’s configure Azure DevOps to manage the CI/CD pipeline. 

  • Create a Project Navigate to [Azure DevOps](https://dev.azure.com), create a new organization (if needed), and click New Project. Name your project (e.g., `node-cicd-app`) and set it to private. 
  • Push Your Code to Azure Repos In the Azure DevOps project, go to Repos > Files and copy the Git commands to push your local repository. Run the following given commands in your project’s folder:  
git remote add origin  
git push -u origin master 

Step 3: Create a Build Pipeline (CI) 

Next, we’ll create a build pipeline that automatically builds and tests the code every time it’s pushed to the repository. 

  • Create a New Pipeline Go to Pipelines > New Pipeline Choose Azure Repos Git as the source, then select your repository. Select Classic Editor to set up the pipeline visually. 
  • Configure Build Pipeline Select Empty Job. Name the pipeline (`Node.js Build Pipeline`) and choose an agent pool based on your environment (e.g., Hosted Ubuntu 18.04 for Linux or Hosted Windows 2019 for Windows). 
  • Add Tasks to the Pipeline Node.js tool installer, use this task to specify the Node.js version for the pipeline. 

npm Task: Command: `install` 

Working directory: `${Build.SourcesDirectory}` 

npm Task: Command: `run build` (if you have a build script, otherwise skip). 

npm Task (Optional): Command: `run test` (if you have unit tests). 

  • Archive the Build Artifacts Add an Archive Files task to compress the output folder into a `.zip` file for faster deployment. Specify the folder to archive (e.g., `public/`, `dist/`, or the relevant output folder). 
  • Publish Build Artifacts Add a Publish Build Artifacts task to store the build outputs. Artifact name: `drop` Path to publish: `${Build.ArtifactStagingDirectory}` 
  • Enable Continuous Integration (CI) In the pipeline settings, enable Continuous Integration to trigger the pipeline whenever code is pushed to the repository. 
  • Save and Run the Pipeline Click Save and Queue to run the pipeline. 

Step 4: Create a Release Pipeline (CD) 

With the build pipeline in place, we’ll now configure a release pipeline to deploy the application to Azure App Service. 

  • Create an Azure App Service In the [Azure Portal](https://portal.azure.com), create an App Service (select Node.js as the runtime stack). 
  • Create a Release Pipeline In Azure DevOps, go to Pipelines > Releases and create a new release pipeline. Select Empty Job and rename the stage to Dev Deployment (or similar). Click Add an Artifact, select the build pipeline, and choose the latest version. 
  • Add Deployment Tasks In the Tasks tab, add an Azure App Service Deploy task. Configure the task: Select your Azure subscription. Choose the App Service created in Azure. Set the package or folder path to `$(System.DefaultWorkingDirectory)/**/*.zip` (the `.zip` file generated in the build pipeline). 
  • Enable Continuous Deployment (CD) In the Triggers tab, enable Continuous Deployment so that every successful build automatically triggers a deployment to Azure. 
  • Run the Release Pipeline Save the release pipeline and create a new release to deploy the application to Azure App Service. 

Step 5: Test Your Application 

Once the release pipeline has deployed your application, test it by visiting the App Service URL: https://azurewebsites.net 

You should see the message: "Hello from CI/CD Pipeline!" 

Step 6: Monitoring and Troubleshooting 

A fast deployment pipeline means little if your application breaks in production and you have no idea why. That is why monitoring and logging are essential in any CI/CD setup for Node.js.

After deploying your application using Azure DevOps, the next step is to ensure it behaves as expected. Start by adding structured logging to your codebase. Tools like Winston can capture real-time information about requests, errors, and system behavior, making it easier to investigate issues when something goes wrong.

At a minimum, you should log:

  • Incoming HTTP requests
  • Deployment-related events
  • Warnings, errors, and failed operations
  • Timestamps and contextual metadata

Once basic logging is in place, connect your logs to a monitoring platform. If you're deploying on Azure, you can use Application Insights to visualize performance metrics, error rates, response times, and more. For teams using other stacks, external services like Datadog, New Relic, or Loggly can serve the same purpose.

Monitoring becomes even more powerful when paired with deployment slots. You can compare performance and stability between staging and production after a slot swap, helping you detect regressions early.

In short, automation helps you ship faster, but observability ensures what you ship actually works. Both should be part of your CI/CD checklist.

Best Practices for CI/CD Pipeline Configuration

Once your pipeline is up and running, refining how it’s built and managed can significantly improve your delivery speed, stability, and developer experience. Here are some field-tested best practices to make your CI/CD setup more efficient and production-ready.

1. Push Code in Small, Trackable Batches

Avoid bundling too many changes into a single commit or pull request. Frequent, smaller commits make it easier to isolate bugs, speed up reviews, and minimize deployment risk. It also helps your automated tests deliver faster feedback, which is critical in continuous integration.

2. Build Once, Promote Across All Stages

Your build artifact (such as a .zip file, Docker image, or compiled bundle) should be generated once during the pipeline and reused in all environments such as test, staging, and production. Rebuilding the same code for different stages introduces risk and inconsistency. Azure DevOps supports artifact promotion natively.

3. Reuse Pipeline Templates for Common Steps

Avoid repeating the same YAML or task definitions across projects. Instead, use shared templates for common actions like linting, running unit tests, or Docker packaging. This keeps your pipelines clean, easier to update, and aligned across teams.

4. Automate Testing That Impacts Delivery

CI/CD pipelines should include tests that validate every critical part of your application. This includes unit tests, integration tests, and regression tests. These should run automatically on every commit or pull request. Reserve manual testing for exploratory or UI-driven checks.

5. Keep Your Pipeline Fast and Efficient

A slow CI/CD pipeline discourages developers from pushing code often. Aim to keep your build and deploy cycles under 10 minutes. Use parallel jobs, dependency caching, and lightweight containers to reduce waiting time and improve feedback loops.

6. Treat Your Pipeline as a Secure Environment

Your pipeline has access to source code, secrets, and deployment infrastructure. Apply the same security principles as production: encrypt secrets, use secure service connections, implement role-based access control, and enable audit logs.

7. Use Preview Environments for Every Feature

For larger features or high-risk changes, spin up temporary environments automatically. These short-lived preview deployments allow teams to validate changes in isolation before merging. Tools like Azure Resource Manager templates, Terraform, or Docker Compose can help automate this process.

8. Use Progressive Deployment Strategies

Instead of pushing changes directly to all users, adopt strategies like blue-green deployments or canary releases. These reduce downtime and allow teams to monitor the new version in production without fully replacing the old one.

9. Track Pipeline Health with Metrics and Logs

Use dashboards and logs to monitor how your pipeline performs over time. Track metrics like build failure rates, test pass percentages, average deployment time, and rollback incidents. This helps teams identify patterns and continuously improve pipeline performance.

10. Involve the Whole Team in CI/CD Ownership

CI/CD is not just for DevOps or backend developers. Everyone involved in shipping features like engineers, QA, product managers etc should understand how the pipeline works. Encourage shared responsibility for build quality, release confidence, and rollback readiness.

Want to Take Your CI/CD Further?

Whether it's reducing build times, enabling zero-downtime rollouts, or integrating cloud-native tools, our team at Prioxis can help optimize your CI/CD architecture to support real-world demands. Let’s explore what’s possible for your product team.

Book a quick discovery call

Concluding Remarks 

By following this guide, you’ve set up a complete CI/CD pipeline for your Node.js application using Azure DevOps. This pipeline automates code building, testing, and deployment, ensuring consistent and reliable delivery of your application. 

For more advanced workflows, explore multi-stage YAML pipelines and infrastructure as code (IaC) using tools like Terraform or Bicep. 

  • 01What are the key benefits of using CI/CD for Node.js applications?

    • CI/CD automates your build, test, and deployment process. For Node.js apps, this means faster releases, fewer bugs, consistent deployments, and better collaboration across teams. It also makes rollback and environment management easier.

  • 02How to setup CI CD pipeline in Azure DevOps?

    • Connect your repo, create a build pipeline for installing dependencies and running tests, publish the build artifact, then set up a release pipeline to deploy your app. Azure DevOps also supports slot swapping, environment variables, and automatic triggers on code changes.