forked from Azure-Samples/nodejs-appsvc-cosmosdb-bottleneck
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathazure-pipelines.yml
138 lines (122 loc) · 4.01 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
128
129
130
131
132
133
134
135
136
137
138
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- main
pool:
vmImage: ubuntu-latest
variables:
webAppName: '<Name of your webapp>'
serviceConnection: '<Name of your webARM Service connection>'
azureSubscriptionId: '<Azure subscriptionId>'
loadTestResource: '<Name of your load test resource>'
loadTestResourceGroup: '<Name of your load test resource group>'
location: 'EAST US'
stages:
- stage: Build
displayName: Build
jobs:
- job: Build
displayName: Build
pool:
vmImage: windows-latest
steps:
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
- stage: Deploy
displayName: Deploy
dependsOn: Build
condition: succeeded()
jobs:
- job: Deploy
displayName: Deploy
pool:
vmImage: windows-latest
steps:
- task: AzureResourceManagerTemplateDeployment@3
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: $(serviceConnection)
subscriptionId: $(azureSubscriptionId)
action: 'Create Or Update Resource Group'
resourceGroupName: '$(webAppName)-rg'
location: 'East US'
templateLocation: 'Linked artifact'
csmFile: '$(System.DefaultWorkingDirectory)/windows-webapp-template.json'
overrideParameters: '-webAppName $(webAppName) -hostingPlanName $(webAppName)-host -appInsightsLocation "East US" -databaseAccountId $(webAppName)db -databaseAccountLocation "East US"'
deploymentMode: 'Incremental'
deploymentOutputs: 'output'
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$deploymentOutput= ConvertFrom-Json '$(output)'
$connectionStringValue= $deploymentOutput.azureCosmosDBAccountKeys.value
Write-Host "##vso[task.setvariable variable=connectionString;issecret=true;]$connectionStringValue"
- task: AzureAppServiceSettings@1
inputs:
azureSubscription: $(serviceConnection)
appName: '$(webAppName)'
resourceGroupName: '$(webAppName)-rg'
appSettings: |
[
{
"name": "CONNECTION_STRING",
"value": "$(connectionString)",
"slotSetting": false
},
{
"name": "MSDEPLOY_RENAME_LOCKED_FILES",
"value": 1,
"slotSetting": false
},
{
"name": "SCM_DO_BUILD_DURING_DEPLOYMENT",
"value": true,
"slotSetting": false
},
{
"name": "HEADER_VALUE",
"value": "$(mySecret)",
"slotSetting": false
}
]
- task: DownloadPipelineArtifact@2
inputs:
artifact: drop
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: $(serviceConnection)
appType: 'webApp'
WebAppName: $(webAppName)
packageForLinux: '$(Pipeline.Workspace)/$(Build.BuildId).zip'
ScriptType: 'Inline Script'
InlineScript: 'npm install'
- stage: LoadTest
displayName: Load Test
dependsOn: Deploy
condition: succeeded()
jobs:
- job: LoadTest
displayName: Load Test
pool:
vmImage: ubuntu-latest
steps:
- task: AzureLoadTest@1
inputs:
azureSubscription: $(serviceConnection)
loadTestConfigFile: 'SampleApp.yaml'
resourceGroup: $(loadTestResourceGroup)
loadTestResource: $(loadTestResource)
- publish: $(System.DefaultWorkingDirectory)/loadTest
artifact: results