Skip to content

Instantly share code, notes, and snippets.

@PlagueHO
Created January 24, 2021 06:39
Show Gist options
  • Save PlagueHO/b3739eda14b635e2593dbafcc6a7d937 to your computer and use it in GitHub Desktop.
Save PlagueHO/b3739eda14b635e2593dbafcc6a7d937 to your computer and use it in GitHub Desktop.
Azure DevOps Multi-Stage YAML Pipeline triggered off Main Branch with access to Secrets & Service Connections and using Environments
trigger:
branches:
include:
- 'main'
pr: none
stages:
- stage: Build
jobs:
- template: templates/build.yml
- stage: QA
displayName: 'Quality Assurance'
jobs:
- deployment: deploy_qa
displayName: 'Deploy to QA'
pool:
vmImage: 'Ubuntu-16.04'
environment: 'QA'
variables:
- group: 'QA Secrets'
strategy:
runOnce:
deploy:
steps:
- task: AzureResourceManagerTemplateDeployment@3
displayName: 'Deploy Azure Resources'
inputs:
azureResourceManagerConnection: 'Azure QA'
subscriptionId: '72ad9153-ecab-48c9-8a7a-d61f2390df78'
resourceGroupName: 'dsr-qa-rg'
location: 'East US'
csmFile: '$(Pipeline.Workspace)/arm/azuredeploy.json'
overrideParameters: '-sqlServerName dsr-qa-sql -sqlDatabaseName dsrqadb -sqlAdministratorLoginUsername $(SQLAdministratorLoginUsername) -sqlAdministratorLoginPassword $(SQLAdministratorLoginPassword) -hostingPlanName "dsr-qa-asp" -webSiteName "dsrqaapp"'
- stage: Production
displayName: 'Release to Production'
jobs:
- deployment: deploy_production
displayName: 'Deploy to Production'
pool:
vmImage: 'Ubuntu-16.04'
environment: 'PRODUCTION'
variables:
- group: 'PRODUCTION Secrets'
strategy:
runOnce:
deploy:
steps:
- task: AzureResourceManagerTemplateDeployment@3
displayName: 'Deploy Azure Resources'
inputs:
azureResourceManagerConnection: 'Azure PRODUCTION'
subscriptionId: '72ad9153-ecab-48c9-8a7a-d61f2390df78'
resourceGroupName: 'dsr-production-rg'
location: 'East US'
csmFile: '$(Pipeline.Workspace)/arm/azuredeploy.json'
overrideParameters: '-sqlServerName dsr-production-sql -sqlDatabaseName dsrproductiondb -sqlAdministratorLoginUsername $(SQLAdministratorLoginUsername) -sqlAdministratorLoginPassword $(SQLAdministratorLoginPassword) -hostingPlanName "dsr-production-asp" -webSiteName "dsrproductionapp"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment