Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
trigger:
- azure-pipelines

pool:
vmImage: 'ubuntu-latest'

variables:
projectRoot: '.'
azureSubscription: 'azureSubscription'
acrConnection: 'acrConnection'
acrLoginServer: 'acrincludia2771.azurecr.io'
webAppName: 'app-includia-iot-2771'
imageName: 'includia-api'
tag: '$(Build.BuildId)'
buildContext: '.'
dockerfilePath: 'Dockerfile'

stages:
- stage: Build
displayName: Build and Test
jobs:
- job: Build
displayName: Build, Test and Push
steps:

- task: DotNetCoreCLI@2
displayName: 'Run Unit Tests'
inputs:
command: 'test'
projects: '$(projectRoot)/**/*.Tests.csproj'
arguments: '--configuration Release --logger trx --collect "Code coverage"'
publishTestResults: true

- task: Docker@2
displayName: 'Login to ACR'
inputs:
command: login
containerRegistry: $(acrConnection)

- task: Docker@2
displayName: 'Build and Push Docker Image'
inputs:
command: buildAndPush
repository: $(imageName)
dockerfile: '$(projectRoot)/Dockerfile'
buildContext: '$(projectRoot)'
containerRegistry: $(acrConnection)
tags: |
$(tag)
latest

- stage: Deploy
displayName: Deploy to Azure
dependsOn: Build
condition: succeeded()
jobs:
- job: Deploy
displayName: Deploy to Web App Container
steps:
- task: AzureWebAppContainer@1
displayName: 'Azure Web App Deploy'
inputs:
azureSubscription: $(azureSubscription)
appName: $(webAppName)
containers: '$(acrLoginServer)/$(imageName):$(tag)'
appSettings: '-ConnectionStrings__OracleDb "$(ORACLE_DB)" -ConnectionStrings__MongoDb "$(MONGO_DB)" -Jwt__Key "$(JWT_KEY)"'