This repository has been archived by the owner on Jun 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.bicep
192 lines (178 loc) · 4.39 KB
/
main.bicep
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
//
// Bicep template to create the Azure resources
//
// Build for Bicep 0.2
//
// Based on: https://github.com/Azure/bicep/tree/2d1f43e57ccfbc117e0d6a9709e0b71377e9a83b/docs/examples/101/function-app-create
param TOTORO_MAILCHIMP_APIKEY string
param TOTORO_MAILCHIMP_LIST_ID string
param TOTORO_BASECAMP_BOTURL string
param location string = resourceGroup().location
var appName = 'bc-totorobot'
param functionRuntime string = 'custom'
// remove dashes for storage account name
var storageAccountName = format('{0}', replace(appName, '-', ''))
var appTags = {
AppName: appName
}
// Storage Account
resource storageAccount 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
tier: 'Standard'
}
kind: 'StorageV2'
properties: {
supportsHttpsTrafficOnly: true
encryption: {
services: {
file: {
keyType: 'Account'
enabled: true
}
blob: {
keyType: 'Account'
enabled: true
}
}
keySource: 'Microsoft.Storage'
}
accessTier: 'Hot'
}
tags: appTags
}
// Blob Services for Storage Account
resource blobServices 'Microsoft.Storage/storageAccounts/blobServices@2019-06-01' = {
name: '${storageAccount.name}/default'
properties: {
cors: {
corsRules: []
}
deleteRetentionPolicy: {
enabled: true
days: 7
}
}
}
// Workspace & associated App Insights resource
resource workspace 'Microsoft.OperationalInsights/workspaces@2020-08-01' = {
name: appName
location: location
properties: {
retentionInDays: 7
sku: {
name: 'Free'
}
}
}
resource appInsights 'Microsoft.Insights/components@2020-02-02-preview' = {
name: appName
location: location
kind: 'web'
properties: {
Application_Type: 'web'
WorkspaceResourceId: workspace.id
publicNetworkAccessForIngestion: 'Enabled'
publicNetworkAccessForQuery: 'Enabled'
}
tags: appTags
}
// App Service
resource appService 'Microsoft.Web/serverFarms@2020-06-01' = {
name: appName
location: location
kind: 'linux'
sku: {
name: 'Y1'
tier: 'Dynamic'
size: 'Y1'
family: 'Y'
capacity: 0
}
properties: {
reserved: true
}
tags: appTags
}
// Function App
resource functionApp 'Microsoft.Web/sites@2020-06-01' = {
name: appName
location: location
kind: 'functionapp,linux'
properties: {
enabled: true
hostNameSslStates: [
{
name: '${appName}.azurewebsites.net'
sslState: 'Disabled'
hostType: 'Standard'
}
{
name: '${appName}.scm.azurewebsites.net'
sslState: 'Disabled'
hostType: 'Standard'
}
]
serverFarmId: appService.id
siteConfig: {
appSettings: [
{
name: 'AzureWebJobsStorage'
value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${listKeys(storageAccount.id, storageAccount.apiVersion).keys[0].value}'
}
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: appInsights.properties.InstrumentationKey
}
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: 'InstrumentationKey=${appInsights.properties.InstrumentationKey}'
}
{
name: 'FUNCTIONS_WORKER_RUNTIME'
value: functionRuntime
}
{
name: 'FUNCTIONS_EXTENSION_VERSION'
value: '~3'
}
{
name: 'TOTORO_PRODUCTION'
value: 'true'
}
{
name: 'TOTORO_MAILCHIMP_APIKEY'
value: TOTORO_MAILCHIMP_APIKEY
}
{
name: 'TOTORO_MAILCHIMP_LIST_ID'
value: TOTORO_MAILCHIMP_LIST_ID
}
{
name: 'TOTORO_BASECAMP_BOTURL'
value: TOTORO_BASECAMP_BOTURL
}
]
linuxFxVersion: ''
use32BitWorkerProcess: false
}
scmSiteAlsoStopped: false
clientAffinityEnabled: false
clientCertEnabled: false
hostNamesDisabled: false
dailyMemoryTimeQuota: 0
httpsOnly: true
redundancyMode: 'None'
}
tags: appTags
}
// Function App Binding
resource functionAppBinding 'Microsoft.Web/sites/hostNameBindings@2020-06-01' = {
name: '${functionApp.name}/${functionApp.name}.azurewebsites.net'
properties: {
siteName: functionApp.name
hostNameType: 'Verified'
}
}