By Abhishek Kumar — Azure Expert | Technical Architect
🚀 Build → Containerize → Deploy → Scale
This is the journey we’re taking today with Azure Functions, Azure Kubernetes Service, and Azure DevOps—all working in harmony to turn your code into a production-ready microservice.
Whether you’re starting with serverless or transitioning to microservices, this guide helps you bridge both worlds.
✅ Prerequisites
Before diving in, ensure you have:
- An Azure account
- An Azure DevOps project
- VS Code or any IDE
- Docker installed locally
- Azure CLI and AKS CLI tools
kubectlinstalled
📁 Step 1: Project Folder Structure
Let’s define a clean structure:
pgsqlCopyEditazure-function-aks-deploy/
├── MyFunctionApp/
│ ├── __init__.py
│ └── function_app.py
├── host.json
├── requirements.txt
├── Dockerfile
├── kubernetes/
│ ├── deployment.yaml
│ └── service.yaml
├── .azure-pipelines/
│ └── azure-pipelines.yml
└── README.md
⚙️ Step 2: Create Your Azure Function
Use the Azure Functions Core Tools:
func init MyFunctionApp --python
cd MyFunctionApp
func new --name HelloWorldFunction --template "HTTP trigger" --authlevel "anonymous"
This will generate a simple HTTP-triggered function.
Example __init__.py:
import logging
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
name = req.params.get('name')
return func.HttpResponse(f"Hello {name or 'world'}!")
📦 Step 3: Add Requirements and Host File
requirements.txt:
azure-functions
host.json:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true
}
}
}
}
🐳 Step 4: Add Docker Support
Dockerfile (at root level):
FROM mcr.microsoft.com/azure-functions/python:4-python3.9
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY . /home/site/wwwroot
RUN pip install -r /home/site/wwwroot/requirements.txt
This tells Docker how to build your function app inside a container.
☸️ Step 5: Create Kubernetes Deployment Files
kubernetes/deployment.yaml:
Version: apps/v1
kind: Deployment
metadata:
name: azure-function-deployment
spec:
replicas: 1
selector:
matchLabels:
app: azure-function
template:
metadata:
labels:
app: azure-function
spec:
containers:
- name: azure-function
image: <ACR_NAME>.azurecr.io/azure-function:latest
ports:
- containerPort: 80
kubernetes/service.yaml:
apiVersion: v1
kind: Service
metadata:
name: azure-function-service
spec:
selector:
app: azure-function
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer
🏗️ Step 6: Azure DevOps CI/CD Pipeline Setup
Create a new pipeline:
Inside .azure-pipelines/azure-pipelines.yml
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
variables:
imageName: 'azure-function'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'
- task: Docker@2
displayName: Build and Push Docker image
inputs:
containerRegistry: '<your ACR service connection>'
repository: '$(imageName)'
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
tags: |
latest
- task: Kubernetes@1
displayName: Deploy to AKS
inputs:
connectionType: 'Azure Resource Manager'
azureSubscription: '<your Azure subscription>'
azureResourceGroup: '<your resource group>'
kubernetesCluster: '<your AKS cluster>'
namespace: 'default'
command: apply
useConfigurationFile: true
configuration: |
$(System.DefaultWorkingDirectory)/kubernetes/deployment.yaml
$(System.DefaultWorkingDirectory)/kubernetes/service.yaml
🔐 Don’t forget to create a service connection in Azure DevOps for both ACR and AKS.
🧪 Step 7: Run and Validate
Once you commit your changes:
- The pipeline will:
- Build the Docker image
- Push it to ACR
- Deploy it to AKS
You can check your deployment using:
kubectl get pods
kubectl get svc
You’ll receive an external IP from the LoadBalancer service. Hit the URL:
http://<EXTERNAL-IP>?name=Abhishek
You’ll see: Hello Abhishek! 🎉

🔁 Optional Enhancements
- Enable horizontal pod autoscaler.
- Add monitoring using Azure Monitor or Prometheus.
- Add secrets via Azure Key Vault.
- Use Helm instead of raw YAML.
- Split dev/stage/prod using environments or namespaces.
📌 Summary
| Step | What You Did |
|---|---|
| ✅ 1 | Created Azure Function |
| ✅ 2 | Containerized it using Docker |
| ✅ 3 | Wrote Kubernetes YAMLs |
| ✅ 4 | Set up Azure DevOps pipeline |
| ✅ 5 | Pushed and deployed to AKS |
🎙️ Abhishek’s Take
As developers, we often get caught between writing clean code and wrestling with infrastructure. What I love about this approach—using Azure Functions with Docker, AKS, and Azure DevOps—is how seamlessly it bridges serverless innovation with Kubernetes power.
You’re not forced to choose between rapid development and production-grade scalability. You get both.
💡 Build once. Containerize fast. Deploy anywhere. That’s the future—and AKS makes it real, even for solo developers or small teams.
This setup empowers new developers to think in microservices, CI/CD, and automation from day one—skills that scale with your career. Start simple, and let Azure scale the rest.
Let’s build smart. Let’s deploy smarter.
🚀 See you on the cloud-native path!
— Abhishek Kumar

Leave a comment