|
| 1 | +trigger: none # Keeps manual trigger option |
| 2 | + |
| 3 | +# Add trigger for CI pipeline completion |
| 4 | +resources: |
| 5 | + pipelines: |
| 6 | + - pipeline: nodeci |
| 7 | + source: node-simple-ci |
| 8 | + trigger: true # Triggers when CI pipeline completes successfully |
| 9 | + |
| 10 | +variables: |
| 11 | +- group: nodeapp-cd-variables |
| 12 | + |
| 13 | +pool: |
| 14 | + vmImage: 'ubuntu-latest' |
| 15 | + |
| 16 | +stages: |
| 17 | +- stage: Infrastructure |
| 18 | + jobs: |
| 19 | + - job: DeployInfrastructure |
| 20 | + steps: |
| 21 | + - download: nodeci # Download artifacts from the CI pipeline |
| 22 | + artifact: drop |
| 23 | + |
| 24 | + - task: AzureResourceManagerTemplateDeployment@3 |
| 25 | + inputs: |
| 26 | + deploymentScope: 'Resource Group' |
| 27 | + azureResourceManagerConnection: 'Azure Pass Azure Subscription' |
| 28 | + subscriptionId: '$(subscriptionId)' |
| 29 | + action: 'Create Or Update Resource Group' |
| 30 | + resourceGroupName: '$(resourceGroup)' |
| 31 | + location: '$(location)' |
| 32 | + templateLocation: 'Linked artifact' |
| 33 | + csmFile: '$(System.DefaultWorkingDirectory)/azuredeploy.json' |
| 34 | + overrideParameters: '-site_host_name "$(webAppName)" -app_svc_plan_name "$(webAppName)-plan"' |
| 35 | + deploymentMode: 'Incremental' |
| 36 | + |
| 37 | +- stage: Staging |
| 38 | + dependsOn: Infrastructure |
| 39 | + jobs: |
| 40 | + - job: DeployStaging |
| 41 | + steps: |
| 42 | + - task: AzureWebApp@1 |
| 43 | + inputs: |
| 44 | + azureSubscription: 'Azure Pass Azure Subscription' |
| 45 | + appName: '$(webAppName)-staging' |
| 46 | + package: '$(Pipeline.Workspace)/nodeci/drop/$(Build.BuildId).zip' |
| 47 | + deployToSlotOrASE: true |
| 48 | + resourceGroupName: '$(resourceGroup)' |
| 49 | + slotName: 'staging' |
| 50 | + |
| 51 | + - task: AzureAppServiceManage@0 |
| 52 | + inputs: |
| 53 | + azureSubscription: 'Azure Pass Azure Subscription' |
| 54 | + Action: 'Start Azure App Service' |
| 55 | + WebAppName: '$(webAppName)' |
| 56 | + SpecifySlot: true |
| 57 | + ResourceGroupName: '$(resourceGroup)' |
| 58 | + Slot: 'staging' |
| 59 | + |
| 60 | + - task: AzureMonitor@1 |
| 61 | + inputs: |
| 62 | + azureSubscription: 'Azure Pass Azure Subscription' |
| 63 | + ResourceGroupName: '$(resourceGroup)' |
| 64 | + ResourceType: 'Microsoft.Web/sites' |
| 65 | + ResourceName: '$(webAppName)' |
| 66 | + AlertRules: | |
| 67 | + [ |
| 68 | + { |
| 69 | + "alertName": "HTTP 5xx Errors", |
| 70 | + "metric": "Http5xx", |
| 71 | + "operator": "GreaterThan", |
| 72 | + "threshold": "0", |
| 73 | + "timeAggregation": "Count", |
| 74 | + "actionGroupId": "/subscriptions/$(subscriptionId)/resourceGroups/$(resourceGroup)/providers/microsoft.insights/actionGroups/emailalert" |
| 75 | + } |
| 76 | + ] |
| 77 | +
|
| 78 | +- stage: Production |
| 79 | + dependsOn: Staging |
| 80 | + jobs: |
| 81 | + - deployment: Production |
| 82 | + environment: Production |
| 83 | + strategy: |
| 84 | + runOnce: |
| 85 | + deploy: |
| 86 | + steps: |
| 87 | + - task: AzureWebApp@1 |
| 88 | + inputs: |
| 89 | + azureSubscription: 'Azure Pass Azure Subscription' |
| 90 | + appName: '$(webAppName)' |
| 91 | + package: '$(Pipeline.Workspace)/nodeci/drop/$(Build.BuildId).zip' |
| 92 | + deployToSlotOrASE: false |
| 93 | + |
| 94 | + - task: AzureAppServiceSettings@1 |
| 95 | + inputs: |
| 96 | + azureSubscription: 'Azure Pass Azure Subscription' |
| 97 | + appName: '$(webAppName)' |
| 98 | + resourceGroupName: '$(resourceGroup)' |
| 99 | + appSettings: | |
| 100 | + [ |
| 101 | + { |
| 102 | + "name": "WEBSITE_NODE_DEFAULT_VERSION", |
| 103 | + "value": "~18", |
| 104 | + "slotSetting": false |
| 105 | + }, |
| 106 | + { |
| 107 | + "name": "APPINSIGHTS_INSTRUMENTATIONKEY", |
| 108 | + "value": "$(appInsightsKey)", |
| 109 | + "slotSetting": false |
| 110 | + } |
| 111 | + ] |
0 commit comments