If you’ve already built your first Azure Pipeline, this next step will show you how to take your code all the way to production — deploying automatically to an Azure Kubernetes Service (AKS) cluster.
This post is a simple walkthrough for anyone who wants to see their containerized app running on Azure, without deep Kubernetes expertise.
What We’ll Do
- Containerize a sample app
- Push the image to Azure Container Registry (ACR)
- Create a YAML-based pipeline to deploy it on AKS
- Validate the deployment
Step 1: Prepare Your App and ACR
Let’s assume you have a simple Node.js or Python app.
Create a Dockerfile
in your project root:
FROM node:18
WORKDIR /app
COPY . .
RUN npm install
CMD ["npm", "start"]
Now, build and push this image to Azure Container Registry (ACR):
az acr build --registry <your-acr-name> --image sampleapp:v1 .
Step 2: Connect Azure DevOps with ACR and AKS
In your Azure DevOps project:
- Go to Project Settings → Service Connections
- Create two connections:
- Azure Resource Manager (for AKS)
- Docker Registry (for ACR)
These connections will authenticate your pipeline securely.
Step 3: Create a Deployment YAML
Add deployment.yaml
in your repo:
apiVersion: apps/v1
kind: Deployment
metadata:
name: sampleapp
spec:
replicas: 2
selector:
matchLabels:
app: sampleapp
template:
metadata:
labels:
app: sampleapp
spec:
containers:
- name: sampleapp
image: <your-acr-name>.azurecr.io/sampleapp:v1
ports:
- containerPort: 80
Step 4: Build the Azure Pipeline
Create .azure-pipelines/aks-deploy.yaml
:
trigger:
- main
pool:
vmImage: ubuntu-latest
variables:
imageName: sampleapp
tag: '$(Build.BuildId)'
stages:
- stage: Build
jobs:
- job: BuildImage
steps:
- task: Docker@2
inputs:
containerRegistry: 'acr-connection'
repository: '$(imageName)'
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
tags: |
$(tag)
- stage: Deploy
dependsOn: Build
jobs:
- job: DeployToAKS
steps:
- task: KubernetesManifest@1
inputs:
action: deploy
kubernetesServiceConnection: 'aks-connection'
manifests: '**/deployment.yaml'
containers: |
$(imageName)=$(imageName):$(tag)
Commit and push this YAML file to your main branch.
Step 5: Run and Verify
Once the pipeline completes, verify the deployment:
kubectl get pods
kubectl get svc
You’ll see your app live on AKS — deployed automatically through Azure DevOps!
Wrapping Up
You’ve just connected CI/CD to a live Kubernetes cluster. From here, you can:
- Add health checks or rolling updates
- Integrate Helm for versioned deployments
- Set up Blue-Green or Canary strategies
This forms the core of a modern cloud deployment pipeline — repeatable, automated, and secure.
Next up: I’ll write about securing pipelines using Azure Key Vault for secret management — stay tuned.
Top comments (0)