Azure DevOps RealTime Projects-Part2
Azure DevOps RealTime Projects-Part2
Schema Deployment
1. Project Scope
This project focuses on automating the deployment of database schema updates using Azure DevOps
Pipelines. When a developer updates the database schema (e.g., adding a new column, modifying a
table), the pipeline will automatically validate and apply the changes to the database.
Key Features:
✅✅Automate database schema changes with version control
✅
✅
Ensure safe deployments with pre-deployment validation
Implement rollback in case of failure
2. Tools Used
● Azure DevOps Pipelines – Automates the deployment process
● Azure SQL Database – Target database for schema changes
● SQL Server Data Tools (SSDT) – Schema validation
● DACPAC (Data-tier Application Package) – Schema deployment format
● SQLCMD – Executes SQL scripts
● Azure Key Vault – Securely stores database credentials
● PowerShell – Automates database operations
3. Analysis Approach
Challenges Without Automation
Proposed Solution
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'windows-latest'
steps:
- task: VSBuild@1
solution: '**/*.sqlproj'
configuration: 'Release'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'DACPAC'
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'windows-latest'
steps:
- task: SqlAzureDacpacDeployment@1
inputs:
azureSubscription: 'MyAzureSubscription'
serverName: 'mydatabase.database.windows.net'
databaseName: 'MyDB'
authenticationType: 'servicePrincipal'
dacpacFile: '$(Build.ArtifactStagingDirectory)/DACPAC/*.dacpac'
If deployment fails:
Unset
sqlpackage.exe /Action:Publish
/SourceFile:"$(Build.ArtifactStagingDirectory)/PreviousDACPAC.dacpac"
5. Conclusion
🚀✅Key Benefits of Automated Database Deployment: ✅ No manual intervention needed
6. Real-Time Example
A financial services company with multiple databases can use this approach to ensure schema
consistency, prevent manual errors, and deploy changes securely without downtime.
Project 2: Implementing Secure DevOps with Azure Policy and
Compliance as Code
1. Project Scope
This project focuses on automating security compliance using Azure Policy and Compliance as Code
within Azure DevOps Pipelines. The goal is to enforce security rules across cloud resources, ensuring
that every deployment follows organizational policies.
Key Features:
✅✅Automate compliance checks for Azure resources
✅
✅
Prevent non-compliant deployments
Use Azure DevOps Pipelines to apply policies automatically
2. Tools Used
● Azure Policy – Defines and enforces compliance rules
● Azure DevOps Pipelines – Automates policy deployment
● Azure CLI / PowerShell – Manages policy definitions
● Azure Monitor & Compliance Center – Tracks violations
● Terraform / Bicep – Deploys policies as code
● Azure Key Vault – Stores secure credentials
3. Analysis Approach
Challenges Without Compliance Automation
Proposed Solution
Unset
{
"mode": "All",
"policyRule": {
"if": {
"field":
"Microsoft.Network/publicIPAddresses/publicIPAllocationMethod",
"equals": "Static"
},
"then": {
"effect": "Deny"
name: 'deny-public-ip'
properties: {
policyType: 'Custom'
mode: 'All'
policyRule: {
if: {
field:
'Microsoft.Network/publicIPAddresses/publicIPAllocationMethod'
equals: 'Static'
then: {
effect: 'Deny'
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'MyAzureSubscription'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
2. If the policy is applied correctly, Azure will deny the request.
Unset
az policy state list --query "[?complianceState=='NonCompliant']"
5. Conclusion
🚀✅Key Benefits of Azure Policy Automation:
✅
✅
Prevents security misconfigurations before deployment
Ensures compliance with organizational policies
6. Real-Time Example
A healthcare company handling sensitive data can use Azure Policy as Code to enforce HIPAA
compliance, ensuring that no resources expose data to the public cloud.
Project 3: Implementing Multi-Stage CI/CD Pipeline with Azure
DevOps for Microservices Deployment
1. Project Scope
This project focuses on setting up a multi-stage CI/CD pipeline in Azure DevOps to deploy a
microservices-based application to Azure Kubernetes Service (AKS). Each microservice will be
built, tested, and deployed independently using a multi-stage pipeline.
Key Features:
✅✅Automate build, test, and deployment of microservices
✅
✅
Use Docker & Kubernetes for containerized deployment
Implement Canary & Rolling updates
2. Tools Used
● Azure DevOps Pipelines – Automate CI/CD
● Azure Kubernetes Service (AKS) – Host containerized microservices
● Docker & Azure Container Registry (ACR) – Store images
● Helm – Manage Kubernetes deployments
● Azure Key Vault – Store sensitive configurations
● Prometheus & Grafana – Monitor microservices
3. Analysis Approach
Challenges Without a Multi-Stage Pipeline
Proposed Solution
✅✅Implement a multi-stage pipeline with separate build, test, and deploy stages
Unset
az group create --name MyResourceGroup --location eastus
Unset
az aks get-credentials --resource-group MyResourceGroup --name
MyAKSCluster
Unset
FROM node:14
WORKDIR /app
COPY package.json .
COPY . .
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: Build
jobs:
- job: Build
steps:
- task: Docker@2
inputs:
command: 'buildAndPush'
repository: 'myacr.azurecr.io/user-service'
dockerfile: 'microservices/user-service/Dockerfile'
containerRegistry: 'MyAzureContainerRegistry'
tags: '$(Build.BuildId)'
- task: Docker@2
inputs:
command: 'buildAndPush'
repository: 'myacr.azurecr.io/order-service'
dockerfile: 'microservices/order-service/Dockerfile'
containerRegistry: 'MyAzureContainerRegistry'
tags: '$(Build.BuildId)'
Unset
apiVersion: apps/v1
kind: Deployment
metadata:
name: user-service
spec:
replicas: 2
selector:
matchLabels:
app: user-service
template:
metadata:
labels:
app: user-service
spec:
containers:
- name: user-service
image: myacr.azurecr.io/user-service:latest
ports:
- containerPort: 3000
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: Deploy
jobs:
- job: Deploy
steps:
- task: Kubernetes@1
inputs:
azureSubscription: 'MyAzureSubscription'
azureResourceGroup: 'MyResourceGroup'
kubernetesCluster: 'MyAKSCluster'
namespace: 'default'
command: 'apply'
useConfigurationFile: true
configuration: 'k8s-deployment.yaml'
Unset
az keyvault create --name MyKeyVault --resource-group MyResourceGroup
--location eastus
2. Store API keys and database credentials:
Unset
az keyvault secret set --vault-name MyKeyVault --name
"DBConnectionString" --value "Server=myserver;Database=mydb;"
Unset
env:
- name: DB_CONNECTION_STRING
valueFrom:
secretKeyRef:
name: azure-keyvault
key: DBConnectionString
Unset
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
5. Conclusion
🚀✅Key Benefits of Multi-Stage CI/CD Pipeline for Microservices:
✅
✅
Automates deployments across multiple environments
Enables faster releases with minimal downtime
6. Real-Time Example
A large e-commerce platform deploying multiple microservices (cart, orders, payments) can use
Azure DevOps Pipelines to ensure continuous delivery with zero downtime.
Project 4: Implementing Azure DevOps CI/CD Pipeline for
Infrastructure as Code (IaC) using Bicep
1. Project Scope
This project focuses on Infrastructure as Code (IaC) with Bicep to automate the provisioning and
management of Azure resources using Azure DevOps Pipelines. Instead of using ARM templates,
Bicep provides a simpler syntax while still leveraging Azure’s native deployment capabilities.
Key Features:
✅✅Automate Infrastructure Deployment using Bicep
✅
✅
Manage Infrastructure as Code (IaC) in Azure DevOps
Implement Role-Based Access Control (RBAC) policies
2. Tools Used
● Azure DevOps Pipelines – Automate deployments
● Bicep – Declarative IaC language for Azure
● Azure CLI – Manages Azure resources via scripts
● Azure Key Vault – Securely stores credentials
● Azure Storage Account – Stores deployment logs
● PowerShell & YAML – Automation scripting
3. Analysis Approach
Challenges Without Infrastructure as Code (IaC)
Proposed Solution
Unset
git clone https://dev.azure.com/MyOrg/BicepDeployment.git
cd BicepDeployment
mkdir bicep-files
3. Inside the bicep-files folder, create a Bicep template (main.bicep) to deploy an Azure
Storage Account:
Unset
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-09-01'
= {
name: 'myuniquestorageaccount'
sku: {
name: 'Standard_LRS'
kind: 'StorageV2'
Unset
git add .
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'MyAzureSubscription'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az bicep build --file bicep-files/main.bicep
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'MyAzureSubscription'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
Unset
az keyvault create --name MyKeyVault --resource-group MyResourceGroup
--location eastus
Unset
az keyvault secret set --vault-name MyKeyVault --name
"StorageAccountKey" --value "my-secure-key"
Unset
param storageKey string =
resourceId('Microsoft.KeyVault/vaults/secrets', 'MyKeyVault',
'StorageAccountKey')
Unset
resource roleAssignment
'Microsoft.Authorization/roleAssignments@2020-10-01-preview' = {
properties: {
roleDefinitionId:
'/providers/Microsoft.Authorization/roleDefinitions/<role-id>'
principalId: '<pipeline-service-principal>'
Unset
az deployment group show --resource-group MyResourceGroup --name latest
Unset
az deployment group create --resource-group MyResourceGroup --mode
Complete --template-file previous-template.bicep
5. Conclusion
🚀✅Key Benefits of Bicep for IaC in Azure DevOps:
✅
✅
Simplifies Infrastructure as Code with an easy syntax
Ensures consistent deployments across multiple environments
6. Real-Time Example
A financial services company managing multiple Azure environments (Dev, Staging, Prod) can use
Bicep with Azure DevOps to automate and standardize infrastructure deployments while ensuring
security and compliance.
Project 5: Implementing Azure DevOps Pipeline for Automated
Security Scanning using SonarQube and WhiteSource
1. Project Scope
This project focuses on integrating automated security scanning into an Azure DevOps CI/CD
pipeline using SonarQube for code quality analysis and WhiteSource (Mend) for open-source
dependency security checks.
Key Features:
✅✅Identify vulnerabilities early in the development lifecycle
✅
✅
Enforce code quality using SonarQube
Scan for security vulnerabilities in open-source dependencies using WhiteSource
2. Tools Used
● Azure DevOps Pipelines – Automates the security scanning process
● SonarQube – Performs static code analysis
● WhiteSource (Mend) – Scans for open-source security vulnerabilities
● Azure Key Vault – Stores sensitive API keys
● Azure Artifacts – Securely stores scanned and approved builds
● OWASP Dependency-Check – Identifies known vulnerabilities in dependencies
3. Analysis Approach
Challenges Without Security Scanning
Proposed Solution
Unset
az container create --resource-group SecurityRG --name SonarQubeServer
\
3.
Generate a SonarQube Token:
○ Login to http://<SonarQubeServer-IP>:9000
○ Navigate to Administration → Security → Generate Token
4. Store SonarQube Token in Azure Key Vault:
Unset
az keyvault secret set --vault-name SecurityVault --name SonarQubeToken
--value "<generated-token>"
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
variables:
sonarToken: $(SONARQUBE_TOKEN)
steps:
- task: SonarQubePrepare@4
inputs:
SonarQube: 'MySonarQubeService'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: 'my-security-project'
cliProjectName: 'SecureApp'
cliSources: 'src'
cliArguments: '-Dsonar.token=$(sonarToken)'
- task: SonarQubeAnalyze@4
inputs:
pollingTimeoutSec: '300'
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: WhiteSource@21
inputs:
cwd: '$(Build.SourcesDirectory)'
productName: 'SecureApp'
configFile: 'whitesource.config.json'
Unset
- task: Bash@3
inputs:
targetType: 'inline'
script: |
chmod +x dependency-check.sh
5. Conclusion
🚀✅Key Benefits of Security Scanning in Azure DevOps:
✅
✅
Automates vulnerability detection in code and dependencies
Prevents insecure code from being deployed
6. Real-Time Example
A banking institution building an online payment system can integrate SonarQube and WhiteSource
in Azure DevOps to detect vulnerabilities early and ensure compliance with PCI-DSS standards.
Project 6: Implementing Azure DevOps CI/CD Pipeline for
Serverless Applications Using Azure Functions
1. Project Scope
This project focuses on automating the deployment of serverless applications using Azure DevOps
Pipelines and Azure Functions. Serverless computing enables event-driven, scalable applications
without managing infrastructure.
Key Features:
✅✅Automate CI/CD for Azure Functions
✅
✅
Use Azure DevOps Pipelines for Continuous Deployment
Manage Function App configurations using Azure App Configuration
2. Tools Used
● Azure DevOps Pipelines – Automates deployment
● Azure Functions – Serverless compute platform
● Azure Storage Account – Event trigger storage
● Azure Key Vault – Stores API keys and secrets
● Azure Application Insights – Logs and monitors function executions
● PowerShell & YAML – Automates infrastructure provisioning
3. Analysis Approach
Challenges Without CI/CD for Azure Functions
Proposed Solution
Unset
az group create --name FunctionAppRG --location eastus
Unset
az keyvault create --name FunctionAppKeyVault --resource-group
FunctionAppRG --location eastus
Unset
az keyvault secret set --vault-name FunctionAppKeyVault --name
"DBConnectionString" --value
"Server=myserver.database.windows.net;Database=mydb;"
cd FunctionAppRepo
Python
import logging
Unset
git add .
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x'
addToPath: true
- script: |
source env/bin/activate
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.SourcesDirectory)'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/function.zip'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)/function.zip'
artifactName: 'drop'
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: DownloadBuildArtifacts@0
inputs:
artifactName: 'drop'
downloadPath: '$(System.DefaultWorkingDirectory)'
- task: AzureFunctionApp@1
inputs:
azureSubscription: 'MyAzureSubscription'
appType: 'functionApp'
appName: 'MyFunctionApp'
package: '$(System.DefaultWorkingDirectory)/drop/function.zip'
1. Modify function to fetch secrets from Azure Key Vault (function.json):
Unset
{
"bindings": [
"type": "httpTrigger",
"direction": "in",
"authLevel": "function",
"methods": ["get"]
}
],
"scriptFile": "__init__.py",
"env": {
"DB_CONNECTION_STRING":
"@Microsoft.KeyVault(SecretUri=https://FunctionAppKeyVault.vault.azure.
net/secrets/DBConnectionString/)"
Unset
az functionapp update --name MyFunctionApp --resource-group
FunctionAppRG --set appInsightsEnabled=true
Unset
- task: AzureCLI@2
inputs:
azureSubscription: 'MyAzureSubscription'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
Unset
curl
https://myfunctionapp.azurewebsites.net/api/HttpTrigger?code=<function-
key>
5. Conclusion
🚀✅Key Benefits of CI/CD for Serverless Apps in Azure DevOps:
✅
✅
Automates Azure Function deployment for rapid releases
Secures function configurations using Azure Key Vault
6. Real-Time Example
A logistics company can use Azure Functions with DevOps Pipelines to automate order processing
without provisioning servers, ensuring cost efficiency and scalability.
Project 7: Implementing Blue-Green Deployment for an Azure
Web App Using Azure DevOps
1. Project Scope
This project focuses on implementing a Blue-Green Deployment strategy using Azure DevOps
Pipelines and Azure App Service Deployment Slots. The Blue-Green model reduces downtime and
risk by maintaining two identical environments, where one serves live traffic (Blue) while the other
acts as staging (Green) for testing.
Key Features:
✅✅Zero-downtime deployments for web applications
✅
✅
Instant rollback to the previous version if issues occur
Use Azure DevOps Pipelines to automate deployments
2. Tools Used
● Azure DevOps Pipelines – Automates deployment
● Azure App Service – Hosts the web application
● Azure Traffic Manager – Routes traffic between Blue and Green environments
● Azure App Service Deployment Slots – Enables swapping environments
● Azure Key Vault – Stores application secrets
● PowerShell & YAML – Automates infrastructure provisioning
3. Analysis Approach
Challenges Without Blue-Green Deployment
Proposed Solution
✅
✅ Deploy new versions in the Green slot without affecting users
✅ Run tests and validations on the Green slot before switching traffic
Unset
az group create --name BlueGreenRG --location eastus
Unset
az webapp deployment slot create --name blue-webapp --resource-group
BlueGreenRG --slot green
Unset
az keyvault create --name BlueGreenKeyVault --resource-group
BlueGreenRG --location eastus
Unset
az keyvault secret set --vault-name BlueGreenKeyVault --name "APIKey"
--value "SecureAPIKey123"
Step 3: Set Up Azure DevOps Repository and CI Pipeline
Unset
git clone https://dev.azure.com/MyOrg/BlueGreenDeployment.git
cd BlueGreenDeployment
Unset
var builder = WebApplication.CreateBuilder(args);
app.Run();
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '6.x'
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.SourcesDirectory)'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/webapp.zip'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)/webapp.zip'
artifactName: 'drop'
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: DeployToGreen
jobs:
- job: Deploy
steps:
- task: DownloadBuildArtifacts@0
inputs:
artifactName: 'drop'
downloadPath: '$(System.DefaultWorkingDirectory)'
- task: AzureWebApp@1
inputs:
azureSubscription: 'MyAzureSubscription'
appType: 'webApp'
appName: 'blue-webapp'
slotName: 'green'
package: '$(System.DefaultWorkingDirectory)/drop/webapp.zip'
- stage: TestGreenSlot
jobs:
- job: Validate
steps:
- stage: SwapSlots
dependsOn: TestGreenSlot
jobs:
- job: Swap
steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'MyAzureSubscription'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
az webapp deployment slot swap --name blue-webapp
--resource-group BlueGreenRG --slot green
Unset
az webapp deployment slot swap --name blue-webapp --resource-group
BlueGreenRG --slot green
Unset
az network traffic-manager profile create --name BlueGreenTM
--resource-group BlueGreenRG --routing-method Weighted --dns-name
bluegreentm
Unset
az network traffic-manager endpoint create --resource-group BlueGreenRG
--profile-name BlueGreenTM --name blue-endpoint --type azureEndpoints
--target-resource-id
/subscriptions/<sub_id>/resourceGroups/BlueGreenRG/providers/Microsoft.
Web/sites/blue-webapp --weight 100
az network traffic-manager endpoint create --resource-group BlueGreenRG
--profile-name BlueGreenTM --name green-endpoint --type azureEndpoints
--target-resource-id
/subscriptions/<sub_id>/resourceGroups/BlueGreenRG/providers/Microsoft.
Web/sites/blue-webapp/slots/green --weight 0
Unset
az network traffic-manager endpoint update --resource-group BlueGreenRG
--profile-name BlueGreenTM --name green-endpoint --weight 50
5. Conclusion
🚀✅Key Benefits of Blue-Green Deployment in Azure DevOps:
✅
✅
Ensures zero-downtime deployment with deployment slots
Enables instant rollback if the new version has issues
6. Real-Time Example
An e-commerce company launching new website features can use Blue-Green Deployment to test
updates safely and switch traffic seamlessly without downtime.
Project 8: Implementing Azure DevOps CI/CD Pipeline for
Containerized Applications with Azure Kubernetes Service
(AKS) and Helm
1. Project Scope
This project focuses on automating the deployment of containerized applications using Azure
DevOps Pipelines, Azure Kubernetes Service (AKS), and Helm. The goal is to ensure scalability,
high availability, and automated updates for containerized workloads.
Key Features:
✅
✅ Automate CI/CD for Kubernetes deployments
✅
✅
Use Helm for managing Kubernetes manifests
Secure Kubernetes secrets using Azure Key Vault
2. Tools Used
● Azure DevOps Pipelines – Automates build and deployment
● Azure Kubernetes Service (AKS) – Hosts containerized workloads
● Docker & Azure Container Registry (ACR) – Stores container images
● Helm – Manages Kubernetes deployments
● Azure Key Vault – Secures Kubernetes secrets
● Prometheus & Grafana – Monitors AKS workloads
3. Analysis Approach
Challenges Without Automated Kubernetes Deployments
Proposed Solution
✅
✅✅Use Azure DevOps CI/CD Pipelines to automate deployments
Leverage Helm for versioned Kubernetes deployments
Unset
az group create --name AKSRG --location eastus
Unset
az aks get-credentials --resource-group AKSRG --name MyAKSCluster
Unset
az keyvault create --name AKSKeyVault --resource-group AKSRG --location
eastus
Unset
az keyvault secret set --vault-name AKSKeyVault --name
"DBConnectionString" --value "Server=mydbserver;Database=mydb;"
Unset
git clone https://dev.azure.com/MyOrg/KubernetesApp.git
cd KubernetesApp
Unset
FROM node:14
WORKDIR /app
COPY package.json .
COPY . .
EXPOSE 3000
Unset
git add .
Step 4: Create an Azure DevOps CI Pipeline for Building and Pushing Docker Images
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Docker@2
inputs:
command: 'buildAndPush'
repository: 'myacr.azurecr.io/kubernetesapp'
dockerfile: 'Dockerfile'
containerRegistry: 'MyAzureContainerRegistry'
tags: '$(Build.BuildId)'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'drop'
Unset
apiVersion: v2
name: kubernetesapp
version: 1.0.0
appVersion: "1.0"
Unset
apiVersion: apps/v1
kind: Deployment
metadata:
name: kubernetesapp
spec:
replicas: 2
selector:
matchLabels:
app: kubernetesapp
template:
metadata:
labels:
app: kubernetesapp
spec:
containers:
- name: kubernetesapp
image: myacr.azurecr.io/kubernetesapp:latest
ports:
- containerPort: 3000
Unset
apiVersion: v1
kind: Service
metadata:
name: kubernetesapp
spec:
type: LoadBalancer
selector:
app: kubernetesapp
ports:
- protocol: TCP
port: 80
targetPort: 3000
Step 6: Create an Azure DevOps CD Pipeline for AKS Deployment Using Helm
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: DeployToAKS
jobs:
- job: Deploy
steps:
- task: HelmDeploy@0
inputs:
azureSubscription: 'MyAzureSubscription'
azureResourceGroup: 'AKSRG'
kubernetesCluster: 'MyAKSCluster'
namespace: 'default'
command: 'upgrade'
chartType: 'FilePath'
chartPath: 'helm/kubernetesapp'
releaseName: 'kubernetesapp'
Unset
kubectl autoscale deployment kubernetesapp --cpu-percent=50 --min=2
--max=5
Unset
kubectl get hpa
Unset
helm repo add prometheus-community
https://prometheus-community.github.io/helm-charts
Unset
helm install grafana stable/grafana
✅
✅
Automates Kubernetes deployments with Azure DevOps
Ensures high availability using auto-scaling
6. Real-Time Example
A fintech company deploying microservices-based banking applications can use Azure DevOps, AKS,
and Helm to ensure high availability, automated scaling, and security for its workloads.
Project 9: Implementing Azure DevOps Pipeline for
Infrastructure as Code (IaC) Using Terraform on Azure
1. Project Scope
This project focuses on using Terraform to define, provision, and manage Azure infrastructure
through Azure DevOps Pipelines. Terraform enables Infrastructure as Code (IaC), making it easy to
automate cloud resource provisioning while ensuring consistency and scalability.
Key Features:
✅
✅ Automate Infrastructure Deployment using Terraform
✅
✅
Manage Infrastructure as Code (IaC) in Azure DevOps
Use Remote State for Team Collaboration
2. Tools Used
● Azure DevOps Pipelines – Automates Terraform execution
● Terraform – Manages Azure Infrastructure as Code
● Azure Storage Account – Stores Terraform state files
● Azure Key Vault – Secures Terraform secrets
● PowerShell & YAML – Used for automation scripting
3. Analysis Approach
Challenges Without Infrastructure as Code (IaC)
Proposed Solution
✅
✅ Use Terraform for Infrastructure as Code (IaC)
Unset
az group create --name TerraformRG --location eastus
Unset
az storage account create --name terraformstate1234 --resource-group
TerraformRG --location eastus --sku Standard_LRS
Unset
az storage container create --name tfstate --account-name
terraformstate1234
Unset
az keyvault create --name TerraformKeyVault --resource-group
TerraformRG --location eastus
Unset
az keyvault secret set --vault-name TerraformKeyVault --name "ClientID"
--value "your-client-id"
az keyvault secret set --vault-name TerraformKeyVault --name
"ClientSecret" --value "your-client-secret"
Unset
git clone https://dev.azure.com/MyOrg/TerraformDeployment.git
cd TerraformDeployment
Unset
terraform {
backend "azurerm" {
resource_group_name = "TerraformRG"
storage_account_name = "terraformstate1234"
container_name = "tfstate"
key = "terraform.tfstate"
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "example" {
name = "MyTerraformRG"
Unset
git add .
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: TerraformInstaller@1
inputs:
terraformVersion: 'latest'
- task: TerraformTaskV2@2
inputs:
provider: 'azurerm'
command: 'init'
backendServiceArm: 'MyAzureSubscription'
backendAzureRmResourceGroupName: 'TerraformRG'
backendAzureRmStorageAccountName: 'terraformstate1234'
backendAzureRmContainerName: 'tfstate'
backendAzureRmKey: 'terraform.tfstate'
- task: TerraformTaskV2@2
inputs:
provider: 'azurerm'
command: 'plan'
environmentServiceNameAzureRM: 'MyAzureSubscription'
Step 5: Configure Azure DevOps CD Pipeline for Terraform Apply
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: Deploy
jobs:
- job: ApplyTerraform
steps:
- task: TerraformTaskV2@2
inputs:
provider: 'azurerm'
command: 'apply'
environmentServiceNameAzureRM: 'MyAzureSubscription'
commandOptions: '-auto-approve'
Step 6: Implement Role-Based Access Control (RBAC) Policies
Unset
az role assignment create --assignee "<service-principal-id>" --role
Contributor --scope
"/subscriptions/<subscription-id>/resourceGroups/TerraformRG"
Unset
terraform show
Unset
terraform apply -refresh=false terraform.tfstate.backup
5. Conclusion
🚀 Key Benefits of Terraform for Azure Infrastructure:
✅
✅ Automates Infrastructure Deployment using Terraform & Azure DevOps
6. Real-Time Example
A large enterprise managing multiple cloud environments (Dev, QA, Prod) can use Terraform in
Azure DevOps Pipelines to automate infrastructure provisioning while ensuring consistency and
security across teams.
Project 10: Implementing Azure DevOps CI/CD Pipeline for
Azure API Management (APIM) with Automated API Deployment
1. Project Scope
This project focuses on automating API deployment and management using Azure DevOps Pipelines
and Azure API Management (APIM). The goal is to ensure seamless API versioning, security
enforcement, and automated updates across different environments.
Key Features:
✅
✅ Automate API deployment and versioning using Azure DevOps
✅
✅
Enforce security policies (Rate Limiting, JWT, OAuth, API Keys)
Use Azure API Management (APIM) for API gateway capabilities
2. Tools Used
● Azure DevOps Pipelines – Automates API deployment
● Azure API Management (APIM) – API gateway for managing APIs
● Swagger / OpenAPI – Defines API specifications
● Azure Key Vault – Stores API secrets and keys
● Azure Monitor & App Insights – API logging and monitoring
● PowerShell & YAML – Automation scripting
3. Analysis Approach
Challenges Without API Management & Automation
Proposed Solution
✅✅Automate API deployment, versioning, and security enforcement using Azure DevOps & APIM
✅ Enable monitoring & logging with Azure Monitor and App Insights
Ensure API high availability and load balancing
4. Step-by-Step Implementation
Step 1: Provision an Azure API Management Instance
Unset
az group create --name APIMRG --location eastus
Unset
az apim create --name MyAPIM --resource-group APIMRG --publisher-name
"MyCompany" --publisher-email "admin@mycompany.com" --sku-name
Consumption
Unset
{
"swagger": "2.0",
"info": {
"version": "1.0.0"
},
"paths": {
"/users": {
"get": {
"summary": "Get all users",
"responses": {
"200": {
"description": "OK"
Unset
git add .
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
steps:
- task: OpenApi@1
inputs:
openApiFile: 'swagger.json'
validationRules: 'All'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: 'swagger.json'
artifactName: 'drop'
Unset
trigger:
branches:
include:
- main
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: DeployToAPIM
jobs:
- job: Deploy
steps:
- task: DownloadBuildArtifacts@0
inputs:
artifactName: 'drop'
downloadPath: '$(System.DefaultWorkingDirectory)'
- task: AzureCLI@2
inputs:
azureSubscription: 'MyAzureSubscription'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
Unset
<inbound>
<validate-jwt header-name="Authorization"
failed-validation-httpcode="401">
<openid-config
url="https://login.microsoftonline.com/{tenant-id}/v2.0/.well-known/ope
nid-configuration" />
<audiences>
<audience>api://my-api</audience>
</audiences>
</validate-jwt>
</inbound>
Unset
<inbound>
</inbound>
Unset
az monitor app-insights component create --app MyAPIMInsights
--location eastus --resource-group APIMRG
Unset
<inbound>
<base />
<log-to-eventhub logger-id="apim-logger">
<message>Request received</message>
</log-to-eventhub>
</inbound>
Unset
az apim api policy create --resource-group APIMRG --service-name MyAPIM
--api-id MyAPI --xml-policy-file logging-policy.xml
inputs:
versionSpec: '16.x'
- script: |
5. Conclusion
🚀✅Key Benefits of Azure API Management with DevOps:
✅
✅
Automates API deployments and updates
Enforces security policies (OAuth, JWT, API Keys, Rate Limiting)
6. Real-Time Example
A banking company can use Azure API Management (APIM) and Azure DevOps Pipelines to securely
expose APIs, enforce rate limits, and enable seamless API versioning while ensuring compliance
with security policies.
🎉 Congratulations!
All 10 Azure DevOps
Are Completed! 🎉
Real-Time Projects