-
Notifications
You must be signed in to change notification settings - Fork 117
/
azure-pipelines.yml
127 lines (115 loc) · 4.19 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#
# Microservice : Claims API Microservice
# Language : ASP.NET Core 3.1
# Date: 08-19-2019
# Author: Ganesh Radhakrishnan ([email protected])
#
# Description:
# Pipeline script (yaml) for building and deploying the 'claims-api' .NET Core microservice on AKS.
# The container image will be built and pushed to an ACR & then deployed to AKS
#
# IMPORTANT:
# This pipeline requires the following variables to be set.
# - 'acrSvcConnection' : Create a 'Service Connection' for ACR in Azure DevOps Services (Project settings) and then specify the service connection name.
# - 'azureSubscriptionEndpoint' : Azure DevOps ARM Connection name
# - 'azureContainerRegistry' : Azure Container Registry name
# - 'azureResourceGroup' : Azure Resource Group name
# - 'kubernetesCluster' : Azure Kubernetes Service cluster name
# - 'sqlDbConnectionString' : Azure SQL DB Connection String value. Refer to 'appsettings.json' file.
#
# Additionally, ensure the 'pool' name matches the name of the Azure DevOps Pipeline Agent!
#
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
#
# --------------------------------
# NOTES:
# ID06082020: ganrad01: Updated script to .NET Core 3.1
# ID01292021: ganrad01: Updated script so Helm reads the latest stable chart repo.
# ID03042021: ganrad01: Helm Init task is not required in Helm v3
# --------------------------------
# trigger:
# - azure-pipelines
pool:
name: Default
####
# name: AKS-Agent-Pool
# demands:
# - Agent.OS -equals Linux
# - k8s-cli -equals kubectl
# - k8s-pm -equals helm
####
variables:
acrSvcConnection: <ACR Service Connection>
azureSubscriptionEndpoint: <Specify Azure RM Connection>
azureContainerRegistry: <Azure Container Registry name - name.azurecr.io>
azureResourceGroup: <Azure Resource Group - name>
kubernetesCluster: <Azure Kubernetes Service - name>
sqlDbConnectionString: <Azure SQL DB Connection String>
steps:
- task: FileTransform@1
displayName: Replace values for DB connection string
name: replace_db_Values
inputs:
folderPath: '$(System.DefaultWorkingDirectory)/'
fileType: json
targetFiles: appsettings.json
- script: "echo 'Starting docker Build...'"
displayName: Build start
name: echo_build_start
- task: Docker@2
displayName: Login to ACR
name: docker_login
inputs:
command: login
containerRegistry: $(acrSvcConnection)
- task: Docker@2
displayName: Build and Push to ACR
name: docker_build_push
inputs:
command: buildAndPush
repository: claims-api
Dockerfile: ./dockerfile
tags: |
latest
$(Build.BuildId)
- script: "echo 'Finished docker Build...'"
displayName: Build complete
name: echo_build_complete
- script: "echo 'Starting Helm Deploy...'"
displayName: Helm deploy start
name: echo_helm_start
# ID03042021.so
#- task: HelmDeploy@0
#displayName: Helm init
#name: helm_init
#inputs:
# connectionType: Azure Resource Manager
# azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
# azureResourceGroup: $(azureResourceGroup)
# kubernetesCluster: $(kubernetesCluster)
# command: init
# upgradetiller: false
# waitForExecution: true
# arguments: --client-only ID012921.o
# arguments: --stable-repo-url "https://charts.helm.sh/stable" --client-only
# ID03042021.eo
- task: HelmDeploy@0
displayName: Helm upgrade
name: helm_deploy
inputs:
connectionType: Azure Resource Manager
azureSubscriptionEndpoint: $(azureSubscriptionEndpoint)
azureResourceGroup: $(azureResourceGroup)
kubernetesCluster: $(kubernetesCluster)
command: upgrade
arguments: --namespace dev-dp --create-namespace --set image.repository=$(azureContainerRegistry)/claims-api --set image.tag=$(Build.BuildId) --set sqldb.connectionString="$(sqlDbConnectionString)" --set blue.enabled=true
chartType: filepath
chartPath: $(System.DefaultWorkingDirectory)/claims-api
releaseName: aks-aspnetcore-lab-dp
# overrideValues: image.repository=csulabtest.azurecr.io/claims-api,image.tag=$(Build.BuildId)
install: true
waitForExecution: true
- script: "echo 'Finished Helm Deploy...'"
displayName: Helm deploy end
name: echo_helm_end