- 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
134 lines
4.6 KiB
YAML
134 lines
4.6 KiB
YAML
# Azure DevOps Pipeline - Deploy to Azure App Service
|
|
# Use this pipeline after images have been built and pushed to ACR
|
|
#
|
|
# To use this pipeline:
|
|
# 1. Make sure images exist in ACR (run azure-pipelines.yml first)
|
|
# 2. Update variables below with your Azure resource names
|
|
# 3. Create Azure service connection for App Service deployment
|
|
# 4. Create 'production' environment in Azure DevOps
|
|
# 5. Configure this pipeline in Azure DevOps
|
|
|
|
trigger:
|
|
branches:
|
|
include:
|
|
- main
|
|
tags:
|
|
include:
|
|
- 'v*'
|
|
|
|
pool:
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
variables:
|
|
# Azure Container Registry configuratie
|
|
acrName: 'zdlas' # Pas aan naar jouw ACR naam
|
|
repositoryName: 'cmdb-insight'
|
|
|
|
# Azure App Service configuratie
|
|
resourceGroup: 'rg-cmdb-insight-prod' # Pas aan naar jouw resource group
|
|
backendAppName: 'cmdb-backend-prod' # Pas aan naar jouw backend app naam
|
|
frontendAppName: 'cmdb-frontend-prod' # Pas aan naar jouw frontend app naam
|
|
azureSubscription: 'zuyderland-cmdb-subscription' # Azure service connection voor App Service deployment
|
|
|
|
# Deployment configuratie
|
|
imageTag: 'latest' # Use 'latest' or specific tag like 'v1.0.0'
|
|
|
|
stages:
|
|
- stage: Deploy
|
|
displayName: 'Deploy to Azure App Service'
|
|
jobs:
|
|
- deployment: DeployBackend
|
|
displayName: 'Deploy Backend'
|
|
environment: 'production'
|
|
strategy:
|
|
runOnce:
|
|
deploy:
|
|
steps:
|
|
- task: AzureWebAppContainer@1
|
|
displayName: 'Deploy Backend Container'
|
|
inputs:
|
|
azureSubscription: '$(azureSubscription)'
|
|
appName: '$(backendAppName)'
|
|
containers: '$(acrName).azurecr.io/$(repositoryName)/backend:$(imageTag)'
|
|
deployToSlotOrASE: false
|
|
|
|
- task: AzureCLI@2
|
|
displayName: 'Restart Backend App Service'
|
|
inputs:
|
|
azureSubscription: '$(azureSubscription)'
|
|
scriptType: 'bash'
|
|
scriptLocation: 'inlineScript'
|
|
inlineScript: |
|
|
echo "Restarting backend app service..."
|
|
az webapp restart \
|
|
--name $(backendAppName) \
|
|
--resource-group $(resourceGroup)
|
|
echo "Backend app service restarted successfully"
|
|
|
|
- deployment: DeployFrontend
|
|
displayName: 'Deploy Frontend'
|
|
environment: 'production'
|
|
strategy:
|
|
runOnce:
|
|
deploy:
|
|
steps:
|
|
- task: AzureWebAppContainer@1
|
|
displayName: 'Deploy Frontend Container'
|
|
inputs:
|
|
azureSubscription: '$(azureSubscription)'
|
|
appName: '$(frontendAppName)'
|
|
containers: '$(acrName).azurecr.io/$(repositoryName)/frontend:$(imageTag)'
|
|
deployToSlotOrASE: false
|
|
|
|
- task: AzureCLI@2
|
|
displayName: 'Restart Frontend App Service'
|
|
inputs:
|
|
azureSubscription: '$(azureSubscription)'
|
|
scriptType: 'bash'
|
|
scriptLocation: 'inlineScript'
|
|
inlineScript: |
|
|
echo "Restarting frontend app service..."
|
|
az webapp restart \
|
|
--name $(frontendAppName) \
|
|
--resource-group $(resourceGroup)
|
|
echo "Frontend app service restarted successfully"
|
|
|
|
- job: VerifyDeployment
|
|
displayName: 'Verify Deployment'
|
|
dependsOn:
|
|
- DeployBackend
|
|
- DeployFrontend
|
|
steps:
|
|
- task: AzureCLI@2
|
|
displayName: 'Health Check'
|
|
inputs:
|
|
azureSubscription: '$(azureSubscription)'
|
|
scriptType: 'bash'
|
|
scriptLocation: 'inlineScript'
|
|
inlineScript: |
|
|
echo "Checking backend health..."
|
|
BACKEND_URL="https://$(backendAppName).azurewebsites.net/api/health"
|
|
FRONTEND_URL="https://$(frontendAppName).azurewebsites.net"
|
|
|
|
echo "Backend URL: $BACKEND_URL"
|
|
echo "Frontend URL: $FRONTEND_URL"
|
|
|
|
# Wait a bit for apps to start
|
|
sleep 10
|
|
|
|
# Check backend health
|
|
BACKEND_STATUS=$(curl -s -o /dev/null -w "%{http_code}" $BACKEND_URL || echo "000")
|
|
if [ "$BACKEND_STATUS" = "200" ]; then
|
|
echo "✅ Backend health check passed"
|
|
else
|
|
echo "⚠️ Backend health check returned status: $BACKEND_STATUS"
|
|
fi
|
|
|
|
# Check frontend
|
|
FRONTEND_STATUS=$(curl -s -o /dev/null -w "%{http_code}" $FRONTEND_URL || echo "000")
|
|
if [ "$FRONTEND_STATUS" = "200" ]; then
|
|
echo "✅ Frontend is accessible"
|
|
else
|
|
echo "⚠️ Frontend returned status: $FRONTEND_STATUS"
|
|
fi
|