- Add separate deployment pipeline (azure-pipelines-deploy.yml) for App Service deployment - Add advanced pipeline with deployment slots (azure-pipelines-slots.yml) - Restore azure-pipelines.yml to build-only (no deployment) - Add comprehensive Azure setup documentation: - AZURE-NEW-SUBSCRIPTION-SETUP.md: Complete step-by-step Azure resource setup - AZURE-RESOURCES-OVERVIEW.md: Quick reference for all Azure resources - AZURE-ACR-SHARED-SETUP.md: Guide for shared Container Registry - AZURE-ACR-NAMING-RECOMMENDATION.md: Naming recommendations for Zuyderland - AZURE-PIPELINE-DEPLOYMENT.md: Automated deployment setup guide - AZURE-PIPELINE-QUICK-REFERENCE.md: Quick reference for pipeline variables - AZURE-PIPELINES-USAGE.md: Guide for using build and deployment pipelines - Add setup script (scripts/setup-azure-resources.sh) for automated resource creation - Support for shared ACR across multiple applications
6.4 KiB
Azure Pipelines Usage Guide
Guide for using the separate build and deployment pipelines.
📋 Pipeline Files
1. azure-pipelines.yml - Build and Push Images
Purpose: Builds Docker images and pushes them to Azure Container Registry.
What it does:
- ✅ Builds backend Docker image
- ✅ Builds frontend Docker image
- ✅ Pushes both to ACR with tags:
$(Build.BuildId)andlatest
When to use:
- First time setup (to test image building)
- After code changes (to build new images)
- Before deployment (to ensure images are in ACR)
Configuration:
variables:
acrName: 'zdlas' # Your ACR name
repositoryName: 'cmdb-insight'
dockerRegistryServiceConnection: 'zuyderland-cmdb-acr-connection'
2. azure-pipelines-deploy.yml - Deploy to App Service
Purpose: Deploys existing images from ACR to Azure App Services.
What it does:
- ✅ Deploys backend container to App Service
- ✅ Deploys frontend container to App Service
- ✅ Restarts both App Services
- ✅ Verifies deployment with health checks
When to use:
- After images are built and pushed to ACR
- When you want to deploy/update the application
- For production deployments
Configuration:
variables:
acrName: 'zdlas' # Your ACR name
resourceGroup: 'rg-cmdb-insight-prod' # Your resource group
backendAppName: 'cmdb-backend-prod' # Your backend app name
frontendAppName: 'cmdb-frontend-prod' # Your frontend app name
azureSubscription: 'zuyderland-cmdb-subscription' # Azure service connection
imageTag: 'latest' # Image tag to deploy
🚀 Workflow
Step 1: Build and Push Images
-
Configure
azure-pipelines.yml:- Update
acrNamewith your ACR name - Update
dockerRegistryServiceConnectionwith your service connection name
- Update
-
Create Pipeline in Azure DevOps:
- Go to Pipelines → New pipeline
- Select Existing Azure Pipelines YAML file
- Choose
azure-pipelines.yml - Run the pipeline
-
Verify Images in ACR:
az acr repository list --name zdlas az acr repository show-tags --name zdlas --repository cmdb-insight/backend az acr repository show-tags --name zdlas --repository cmdb-insight/frontend
Step 2: Deploy Application
-
Ensure App Services exist:
- Backend App Service:
cmdb-backend-prod - Frontend App Service:
cmdb-frontend-prod - See
AZURE-NEW-SUBSCRIPTION-SETUP.mdfor setup instructions
- Backend App Service:
-
Configure
azure-pipelines-deploy.yml:- Update all variables with your Azure resource names
- Create Azure service connection for App Service deployment
- Create
productionenvironment in Azure DevOps
-
Create Deployment Pipeline:
- Go to Pipelines → New pipeline
- Select Existing Azure Pipelines YAML file
- Choose
azure-pipelines-deploy.yml - Run the pipeline
-
Verify Deployment:
- Check backend:
https://cmdb-backend-prod.azurewebsites.net/api/health - Check frontend:
https://cmdb-frontend-prod.azurewebsites.net
- Check backend:
🔧 Setup Requirements
For Build Pipeline (azure-pipelines.yml)
Required:
- ✅ Docker Registry service connection (for ACR)
- ✅ ACR exists and is accessible
- ✅ Service connection has push permissions
Setup:
- Create Docker Registry service connection:
- Project Settings → Service connections → New service connection
- Choose Docker Registry → Azure Container Registry
- Select your ACR
- Name:
zuyderland-cmdb-acr-connection
For Deployment Pipeline (azure-pipelines-deploy.yml)
Required:
- ✅ Azure Resource Manager service connection
- ✅ App Services exist in Azure
- ✅
productionenvironment created in Azure DevOps - ✅ Images exist in ACR
Setup:
-
Create Azure service connection:
- Project Settings → Service connections → New service connection
- Choose Azure Resource Manager
- Select your subscription
- Name:
zuyderland-cmdb-subscription
-
Create environment:
- Pipelines → Environments → Create environment
- Name:
production - (Optional) Add approvals for manual control
📝 Typical Usage Scenarios
Scenario 1: First Time Setup
# 1. Build and push images
# Run azure-pipelines.yml → Images in ACR
# 2. Create App Services (manual or via script)
# See AZURE-NEW-SUBSCRIPTION-SETUP.md
# 3. Deploy application
# Run azure-pipelines-deploy.yml → App deployed
Scenario 2: Code Update
# 1. Push code to main branch
git push origin main
# 2. Build pipeline runs automatically
# azure-pipelines.yml → New images in ACR
# 3. Deploy new version
# Run azure-pipelines-deploy.yml → App updated
Scenario 3: Deploy Specific Version
# 1. Update azure-pipelines-deploy.yml
imageTag: 'v1.0.0' # Or specific build ID
# 2. Run deployment pipeline
# Deploys specific version
🔄 Combining Pipelines (Future)
Once you're comfortable with both pipelines, you can:
- Combine them into one pipeline with conditional deployment
- Use deployment slots for zero-downtime updates
- Add approval gates for production deployments
See azure-pipelines-slots.yml for an advanced example with deployment slots.
🛠️ Troubleshooting
Build Pipeline Fails
Issue: "Service connection not found"
- Solution: Verify service connection name matches
dockerRegistryServiceConnectionvariable
Issue: "ACR not found"
- Solution: Check
acrNamevariable matches your ACR name
Deployment Pipeline Fails
Issue: "App Service not found"
- Solution: Verify app names match your Azure resources
Issue: "Environment not found"
- Solution: Create
productionenvironment in Azure DevOps
Issue: "Image not found in ACR"
- Solution: Run build pipeline first to push images to ACR
✅ Checklist
Build Pipeline Setup
- Docker Registry service connection created
azure-pipelines.ymlvariables configured- Pipeline created in Azure DevOps
- Test run successful
- Images visible in ACR
Deployment Pipeline Setup
- Azure Resource Manager service connection created
productionenvironment created- App Services exist in Azure
azure-pipelines-deploy.ymlvariables configured- Deployment pipeline created in Azure DevOps
- Test deployment successful
Workflow: Build first → Deploy second → Verify success!