Define CI&CD in one Azure pipeline

trigger: 
- DEV
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'UAT'
steps: 
- task: NuGetToolInstaller@1
# restore all nuget packages for our solution. In our project we have only one sln file.
- task:
NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
# build the entire solution
- task:
VSBuild@1 inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
# publish the project to create a zip file. here I used in our application SlowCheetah in order to have different appsettings configuration files
- task: DotNetCoreCLI@2
inputs: command: 'publish'
publishWebProjects: true
arguments: '-c $(buildConfiguration)'
# create migrations for our database project
- task: efcore-migration-script-generator-task@0
inputs:
projectpath: '<EF Core project path>'
databasecontexts: 'ApplicationDbContext'
startupprojectpath: '<Default solution project path>'
targetfolder: '$(System.DefaultWorkingDirectory)/migrations'
installdependencies: true
# apply migrations to our Azure database
- task: SqlAzureDacpacDeployment@1
inputs:
azureSubscription: '<AzureSubscriptionName>'
AuthenticationType: 'server'
ServerName: '<Azure ServerName>'
DatabaseName: '<Azure DatabaseName>'
SqlUsername: '<Azure SqlUserName>'
SqlPassword: '<Azure SqlPassword>'
deployType: 'SqlTask'
SqlFile: '$(System.DefaultWorkingDirectory)/**/migrations/ApplicationDbContext.sql'
IpDetectionMethod: 'AutoDetect'
# deploy the files from out publish task to out Azure WebApp service, using WebDeploy method. Also, we can have the option to deploy from a package our application
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: '<AzureSubscriptionName>'
appType: 'webApp'
WebAppName: '<Azure WebAppName>'
UseWebDeploy: true
DeploymentType: 'webDeploy'
packageForLinux: '$(System.DefaultWorkingDirectory)/**/*.zip'

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bogdan Hatis

Bogdan Hatis

2 Followers

Experienced developer, product manager and CTO with a demonstrated history of working in the information technology, services and fintech industry.