-
Notifications
You must be signed in to change notification settings - Fork 942
/
Copy pathdocker-container-functionapp.yml
107 lines (84 loc) · 4.27 KB
/
docker-container-functionapp.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
# Docker image, Azure Container Registry, and Azure Functions app
# Build a Docker image, push it to an Azure Container Registry, and deploy it to an Azure Functions app.
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
- {{ branch }}
resources:
- repo: self
variables:
# ========================================================================
# Mandatory variables
# ========================================================================
# Update Azure.ResourceGroupName value with Azure resource group name.
Azure.ResourceGroupName: '{{#toAlphaNumericString repositoryName 50}}{{/toAlphaNumericString}}'
# Update Azure.ServiceConnectionId value with AzureRm service endpoint.
Azure.ServiceConnectionId: '{{ azureServiceConnectionId }}'
# 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: '{{#toAlphaNumericString repositoryName 46}}{{/toAlphaNumericString}}{{#shortGuid}}{{/shortGuid}}'
# Update FunctionApp.Name value with a name that identifies your new function app. Valid characters are a-z, 0-9, and -.
FunctionApp.Name: '{{#toAlphaNumericString repositoryName 46}}{{/toAlphaNumericString}}{{#shortGuid}}{{/shortGuid}}'
# Update StorageAccount.Name value with Storage account name. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.
StorageAccount.Name: '{{#toAlphaNumericString repositoryName 20}}{{/toAlphaNumericString}}{{#shortGuid}}{{/shortGuid}}'
# Update ServicePlan.Name value with a name of the app service plan.
ServicePlan.Name: '{{#toAlphaNumericString repositoryName 45}}{{/toAlphaNumericString}}-plan'
# ========================================================================
# Optional variables
# ========================================================================
ACR.ImageName: '$(ACR.Name):$(Build.BuildId)'
ACR.FullName: '$(ACR.Name).azurecr.io'
ACR.Sku: 'Standard'
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:
{{ pool }}
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/functionapp.json'
overrideParameters: '-registryName "$(ACR.Name)" -registryLocation "$(Azure.Location)" -functionAppName "$(FunctionApp.Name)" -hostingPlanName "$(ServicePlan.Name)" -storageAccountName "$(StorageAccount.Name)"'
- job: BuildImage
displayName: Build
dependsOn: CreateResources
condition: or(succeeded(), ne(variables['Azure.CreateResources'], 'true'))
pool:
{{ pool }}
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:
{{ pool }}
steps:
- task: AzureFunctionAppContainer@1
displayName: 'Azure Function App on Container Deploy: $(FunctionApp.Name)'
inputs:
azureSubscription: '$(Azure.ServiceConnectionId)'
appName: $(FunctionApp.Name)
imageName: '$(ACR.FullName)/$(ACR.ImageName)'