forked from rakol-ms/nodejs-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebappcontainer.yml
103 lines (81 loc) · 3.51 KB
/
webappcontainer.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
# Docker image, Azure Container Registry, and Azure Web App
# Build a Docker image, push it to an Azure Container Registry, and deploy it to an Azure Web App.
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- master
resources:
- repo: self
variables:
# ========================================================================
# Mandatory variables
# ========================================================================
# Update Azure.ResourceGroupName value with Azure resource group name.
Azure.ResourceGroupName: 'gopiacr'
# Update Azure.ServiceConnectionId value with AzureRm service endpoint.
Azure.ServiceConnectionId: 'GopiSC'
# Update Azure.Location value with Azure Location.
Azure.Location: 'eastus'
# Update ACR.Name value with ACR name. Please note ACR names should be all lower-case and alphanumeric only.
ACR.Name: 'gopiacr5701'
# Update Web.Name value with a name that identifies your new Web app. Valid characters are a-z, 0-9, and -.
WebApp.Name: 'gopiacr3551'
# Update ServicePlan.Name value with a name of the app service plan.
ServicePlan.Name: 'gopiacr-plan'
# ========================================================================
# Optional variables
# ========================================================================
ACR.ImageName: '$(ACR.Name):$(Build.BuildId)'
ACR.FullName: '$(ACR.Name).azurecr.io'
Azure.CreateResources: 'true' # Update Azure.CreateResources to false if you have already created resources like resource group and azure container registry.
System.Debug: 'false'
jobs:
- job: CreateResources
displayName: Create resources
condition: and(succeeded(), eq(variables['Azure.CreateResources'], 'true'))
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: AzureResourceGroupDeployment@2
displayName: 'Azure Deployment:Create Azure Container Registry, Azure WebApp Service'
inputs:
azureSubscription: '$(Azure.ServiceConnectionId)'
resourceGroupName: '$(Azure.ResourceGroupName)'
location: '$(Azure.Location)'
templateLocation: 'URL of the file'
csmFileLink: 'https://raw.githubusercontent.com/Microsoft/azure-pipelines-yaml/master/templates/resources/arm/webapp-on-containers.json'
overrideParameters: '-registryName "$(ACR.Name)" -registryLocation "$(Azure.Location)" -imageName "$(ACR.ImageName)" -webAppName "$(WebApp.Name)" -hostingPlanName "$(ServicePlan.Name)"'
- job: BuildImage
displayName: Build
dependsOn: CreateResources
condition: or(succeeded(), ne(variables['Azure.CreateResources'], 'true'))
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: Docker@1
displayName: 'Build an image'
inputs:
azureSubscriptionEndpoint: '$(Azure.ServiceConnectionId)'
azureContainerRegistry: '$(ACR.FullName)'
imageName: '$(ACR.ImageName)'
command: build
dockerFile: '**/Dockerfile'
- task: Docker@1
displayName: 'Push an image'
inputs:
azureSubscriptionEndpoint: '$(Azure.ServiceConnectionId)'
azureContainerRegistry: '$(ACR.FullName)'
imageName: '$(ACR.ImageName)'
command: push
- job: DeployApp
displayName: Deploy
dependsOn: BuildImage
condition: succeeded()
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: AzureWebAppContainer@1
displayName: 'Azure Web App on Container Deploy: $(WebApp.Name)'
inputs:
azureSubscription: '$(Azure.ServiceConnectionId)'
appName: $(WebApp.Name)
imageName: '$(ACR.FullName)/$(ACR.ImageName)'