Now that you’ve seen how Azure DevOps works and what role pipelines play in the DevOps lifecycle, it’s time to get hands-on. In this blog, we’ll walk through creating a complete CI/CD pipeline using YAML in Azure Pipelines.
We’ll cover:
- Creating a new Azure DevOps project
- Connecting your Git repo
- Writing your first YAML pipeline
- Running and debugging your build
Let’s go step-by-step.
Step 1: Create a New Project in Azure DevOps
- Go to https://dev.azure.com/ and sign in.
- Click on New Project.
- Enter project name (e.g.,
my-first-pipeline
), select Private, and click Create.
Step 2: Push Code to Azure Repos (or Connect GitHub)
You can either:
- Push your local project to the Azure Repo created automatically, OR
- Connect an external GitHub repo (from Pipelines > New Pipeline > GitHub)
Make sure your repo has a basic project setup — for example, a Node.js or Python app with tests.
Step 3: Create Your First Pipeline
- Go to Pipelines > New Pipeline.
- Choose your source (Azure Repos Git or GitHub).
- Select your repository.
- Azure will try to auto-detect a starter pipeline. You can use it or paste your own.
Step 4: Write the YAML for CI
Here’s a basic CI pipeline for a Node.js project:
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '18.x'
displayName: 'Install Node.js'
- script: |
npm install
npm test
displayName: 'Install dependencies and run tests'
- script: npm run build
displayName: 'Build application'
For Python:
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'
- script: |
pip install -r requirements.txt
pytest
displayName: 'Install deps and run tests'
Step 5: Run the Pipeline
Once committed, the pipeline will automatically run.
You’ll see:
- Each step’s status (success/failure)
- Logs for every command
- Artifacts (if any) saved from the build
Step 6: Debug Failures
- Use the logs tab to inspect each task output
- Common issues: missing dependencies, wrong version, permission errors
Step 7: Add Deployment to Azure and Set Up an Azure Service Connection (Optional)
Before your pipeline can deploy to Azure resources, it needs a secure way to authenticate. Azure DevOps handles this using Service Connections.
To create one:
- Go to your Azure DevOps project
- Navigate to Project Settings > Service connections
- Click New service connection
- Choose Azure Resource Manager
- Select Service principal (automatic) (recommended)
- Choose your subscription and authorize access
- Give it a recognizable name (e.g.,
MyServiceConnection
)
This connection will be referenced in your pipeline YAML to authorize deployments.
- task: AzureWebApp@1
inputs:
azureSubscription: 'MyServiceConnection'
appName: 'my-web-app'
package: '$(System.DefaultWorkingDirectory)/**/*.zip'
Best Practices
- Use separate pipelines for CI (build/test) and CD (deploy)
- Store your pipeline YAML in the root of your repo (
azure-pipelines.yml
) - Protect your main branch with build validation policies
- Use variable groups and secrets via Azure Key Vault
What’s Next
In the next blog, we’ll look at using Terraform with Azure DevOps to provision infrastructure as code. We’ll start by writing a basic Terraform script to deploy a resource group, and run it from a pipeline.
From pipelines to infrastructure — this is where DevOps gets powerful.
Top comments (0)