Skip to content

Branch to Environment Mapping

This page documents how Git branches map to Azure environments, which pipeline variable groups are loaded per environment, and the full trigger configuration for each orchestrator.


Branch Mapping Table

Branch PatternTarget EnvironmentAuto-DeployApproval GateDomain
mainProductionNoYes — Release Manageronlinemicrotec.com.sa
masterProductionNoYes — Release Manageronlinemicrotec.com.sa
ProductionProductionNoYes — Release Manageronlinemicrotec.com.sa
StageStageYesNomicrotecstage.com
PreProdPre-ProductionYesNomicrotec-preprod.com
preprodPre-ProductionYesNomicrotec-preprod.com
developDevelopmentYesNomicrotec-test.com
Sprint*DevelopmentYesNomicrotec-test.com
(all others)DevelopmentYesNomicrotec-test.com

Branch Triggers Are Case-Sensitive

The branch triggers use exact names: Stage (capital S), Production (capital P), PreProd (camel-case). Verify branch names match exactly when configuring triggers.

Fast Deploy Exception

The fast-deploy-pipeline.yml pipeline is never triggered automatically. It is always run manually via the Azure DevOps UI with explicit targetEnvironment and service toggle parameters. See Fast Deploy Path.


Environment Resolution Logic

The pipeline resolves the target environment using this PowerShell logic:

powershell
# In initialize.stage.yml
$branch = $env:BUILD_SOURCEBRANCH -replace '^refs/heads/', ''

$environment = switch -Wildcard ($branch) {
    'main'        { 'production' }
    'master'      { 'production' }
    'Production'  { 'production' }
    'Stage'       { 'stage' }
    'PreProd'     { 'preprod' }
    'preprod'     { 'preprod' }
    'uat'         { 'uat' }
    'develop'     { 'dev' }
    'Sprint*'     { 'dev' }
    default       { 'dev' }
}

Write-Host "##vso[task.setvariable variable=ENVIRONMENT;isOutput=true]$environment"

Variable Groups per Environment

Each environment has a dedicated Azure DevOps Library variable group. Pipelines always link container-backend-shared plus the environment-specific secrets group:

yaml
# In pipeline YAML
variables:
  - group: container-backend-shared
  - ${{ if eq(parameters.targetEnvironment, 'production') }}:
    - group: container-backend-secrets-production
  - ${{ if eq(parameters.targetEnvironment, 'stage') }}:
    - group: container-backend-secrets-stage
  - ${{ if eq(parameters.targetEnvironment, 'preprod') }}:
    - group: container-backend-secrets-preprod
  - ${{ if eq(parameters.targetEnvironment, 'uat') }}:
    - group: container-backend-secrets-uat
  - ${{ else }}:
    - group: container-backend-secrets-dev

Variable Group Reference

Variable GroupContents
container-backend-sharedShared vars (NuGet uses System.AccessToken; no secrets)
container-backend-secrets-devDev environment secrets (SQL passwords, Keycloak admin, JWT keys, etc.)
container-backend-secrets-stageStage environment secrets
container-backend-secrets-preprodPreprod environment secrets
container-backend-secrets-uatUAT environment secrets
container-backend-secrets-productionProduction environment secrets

Key Vault Name Values (Non-Standard)

KEY_VAULT_NAME Values Are Non-Standard

Because Key Vault names don't follow a consistent formula, the Key Vault name for each environment must be stored explicitly. Actual names:

EnvironmentKey Vault Name
devmic-erp-be-dev-skv
stagemic-erp-stg-kv
preprodmic-erp-be-preprod-skv
uatmic-erp-uat-kv
production(contact platform team)

Frontend Branch Mapping

The unified-frontend-pipeline.yml uses the same branch-to-environment mapping. Frontend variable groups follow the same pattern:

BranchEnvironmentVariable GroupBlob Storage Account
main/master/productionprodmic-erp-fr-prod-varsmicerpfrprodsa
stage/stagingstagemic-erp-fr-stage-varsmicerpfrstage sa
PreProd/preprodpreprodmic-erp-fr-preprod-varsmicerpfrpreprodsa
uatuatmic-erp-fr-uat-varsmicerpfruatsa
othersdevmic-erp-fr-dev-varsmicerpfrdevsa

Azure DevOps Environment Protection Rules

Azure DevOps Environments enforce approval gates at the pipeline level. These are separate from the variable groups:

ADO EnvironmentProtectionApprovers
productionManual approval requiredRelease Manager, CTO (any 1)
uatNone
preprodNone
stageNone
devNone

The production environment also has:

  • Deployment freeze: No deployments between 4 PM – 8 AM GST (configured as a business hours check)
  • Required checks: Stage smoke tests must be green within last 4 hours

Visualizing Current Deployments

Check what's deployed where:

bash
# List all container app revisions with traffic weights
az containerapp revision list \
  --name accounting \
  --resource-group mic-erp-be-stage-apps-rg \
  --query "[].{name:name, active:properties.active, weight:properties.trafficWeight, image:properties.template.containers[0].image}" \
  --output table

# Check all services in an environment
for svc in accounting hr finance sales purchase inventory distribution fixed-assets notification workflow attachment; do
  echo "=== $svc ==="
  az containerapp show \
    --name $svc \
    --resource-group mic-erp-be-dev-apps-rg \
    --query "properties.latestRevisionName" -o tsv
done

Troubleshooting Branch Triggers

SymptomLikely CauseResolution
Pipeline not triggered on pushBranch filter doesn't matchCheck trigger.branches.include in YAML
Wrong environment targetedBranch name doesn't match exact patternsCheck case sensitivity (PreProd vs preprod)
Variable group not loadedENVIRONMENT variable not set before group referenceEnsure Prepare stage sets ENVIRONMENT before variable group load
Production deploy without approvalADO environment protection not configuredSet up approval gate in ADO Environments page

Internal Documentation — Microtec Platform Team