-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.bicep
More file actions
333 lines (314 loc) · 8.65 KB
/
Copy pathmain.bicep
File metadata and controls
333 lines (314 loc) · 8.65 KB
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
// original file - https://github.com/Azure/bicep/blob/main/docs/examples/101/function-app-create/main.bicep
param location string = resourceGroup().location
param watchlistStorageAccountName string = ''
param watchlistStorageAccountFileShareName string = ''
param watchlistStorageAccountFileShareAccessKey string = ''
param watchlistStorageAccountIncomingContainerOrDirectoryName string = 'incoming'
param watchlistStorageAccountCompletedContainerOrDirectoryName string = 'imported'
param watchlistStorageSubscriptionId string = ''
param watchlistWorkspaceId string = ''
param workspaceSharedKey string = ''
param appNameSuffix string = uniqueString(resourceGroup().id)
var functionAppName = 'functionapp-${appNameSuffix}'
var vaultName = 'vault-${appNameSuffix}'
var appServiceName = 'appservice-${appNameSuffix}'
var blobAppSettings = [
{
name: 'WATCHLIST_STORAGE_INCOMING_CONTAINER_NAME'
value: watchlistStorageAccountIncomingContainerOrDirectoryName
}
{
name: 'WATCHLIST_STORAGE_COMPLETED_CONTAINER_NAME'
value: watchlistStorageAccountCompletedContainerOrDirectoryName
}
]
var fileAppSettings = [
{
name: 'WATCHLIST_STORAGE_ACCOUNT_FILE_SHARE_NAME'
value: watchlistStorageAccountFileShareName
}
{
name: 'WATCHLIST_STORAGE_INCOMING_DIRECTORY_NAME'
value: watchlistStorageAccountIncomingContainerOrDirectoryName
}
{
name: 'WATCHLIST_STORAGE_COMPLETED_DIRECTORY_NAME'
value: watchlistStorageAccountCompletedContainerOrDirectoryName
}
{
name: 'WATCHLIST_STORAGE_ACCOUNT_FILE_SHARE_ACCESS_KEY'
value: '@Microsoft.KeyVault(SecretUri=https://${vaultName}.vault.azure.net/secrets/WATCHLIST-STORAGE-ACCOUNT-FILE-SHARE-ACCESS-KEY)'
}
]
// remove dashes for storage account name
var storageAccountName = format('sta{0}', replace(appNameSuffix, '-', ''))
// Storage Account
resource storageAccount 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
supportsHttpsTrafficOnly: true
encryption: {
services: {
file: {
keyType: 'Account'
enabled: true
}
blob: {
keyType: 'Account'
enabled: true
}
}
keySource: 'Microsoft.Storage'
}
accessTier: 'Hot'
}
}
// Blob Services for Storage Account
resource blobServices 'Microsoft.Storage/storageAccounts/blobServices@2019-06-01' = {
parent: storageAccount
name: 'default'
properties: {
cors: {
corsRules: []
}
deleteRetentionPolicy: {
enabled: true
days: 7
}
}
}
// App Service
resource appService 'Microsoft.Web/serverfarms@2021-01-15' = {
name: appServiceName
location: location
kind: 'functionapp'
sku: {
name: 'EP1'
}
properties: {
reserved: false
}
}
// Function App
resource functionApp 'Microsoft.Web/sites@2020-06-01' = {
name: functionAppName
location: location
kind: 'functionapp'
identity: {
type: 'SystemAssigned'
}
properties: {
enabled: true
hostNameSslStates: [
{
name: '${functionAppName}.azurewebsites.net'
sslState: 'Disabled'
hostType: 'Standard'
}
{
name: '${functionAppName}.scm.azurewebsites.net'
sslState: 'Disabled'
hostType: 'Standard'
}
]
serverFarmId: appService.id
reserved: false
isXenon: false
hyperV: false
siteConfig: {
appSettings: union([
{
name: 'AzureWebJobsStorage'
value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
}
{
name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'
value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
}
{
name: 'FUNCTIONS_WORKER_RUNTIME'
value: 'powershell'
}
{
name: 'FUNCTIONS_EXTENSION_VERSION'
value: '~3'
}
{
name: 'WATCHLIST_STORAGE_ACCOUNT_NAME'
value: watchlistStorageAccountName
}
{
name: 'WATCHLIST_STORAGE_SUBSCRIPTION_ID'
value: watchlistStorageSubscriptionId
}
{
name: 'WATCHLIST_WORKSPACE_ID'
value: watchlistWorkspaceId
}
{
name: 'WATCHLIST_WORKSPACE_SHARED_KEY'
value: '@Microsoft.KeyVault(SecretUri=https://${vaultName}.vault.azure.net/secrets/WATCHLIST-WORKSPACE-SHARED-KEY)'
}
{
name: 'AzureWebJobs.ImportWatchlistsDaily.Disabled'
value: 'true'
}
{
name: 'FUNCTIONS_WORKER_PROCESS_COUNT'
value: '1'
}
{
name: 'PSWorkerInProcConcurrencyUpperBound'
value: '5'
}
], empty(watchlistStorageAccountFileShareName) ? blobAppSettings : fileAppSettings)
}
scmSiteAlsoStopped: false
clientAffinityEnabled: false
clientCertEnabled: false
hostNamesDisabled: false
dailyMemoryTimeQuota: 0
httpsOnly: true
redundancyMode: 'None'
}
}
// Function App Config
resource functionAppConfig 'Microsoft.Web/sites/config@2021-01-15' = {
parent: functionApp
name: 'web'
properties: {
numberOfWorkers: -1
defaultDocuments: [
'Default.htm'
'Default.html'
'Default.asp'
'index.htm'
'index.html'
'iisstart.htm'
'default.aspx'
'index.php'
'hostingstart.html'
]
netFrameworkVersion: 'v4.0'
phpVersion: '5.6'
powerShellVersion: '~7'
requestTracingEnabled: false
remoteDebuggingEnabled: false
httpLoggingEnabled: false
logsDirectorySizeLimit: 35
detailedErrorLoggingEnabled: false
publishingUsername: '$${functionAppName}'
scmType: 'None'
use32BitWorkerProcess: true
webSocketsEnabled: false
alwaysOn: false
managedPipelineMode: 'Integrated'
virtualApplications: [
{
virtualPath: '/'
physicalPath: 'site\\wwwroot'
preloadEnabled: true
}
]
loadBalancing: 'LeastRequests'
experiments: {
rampUpRules: []
}
autoHealEnabled: false
cors: {
allowedOrigins: [
'https://functions.azure.com'
'https://functions-staging.azure.com'
'https://functions-next.azure.com'
]
supportCredentials: false
}
localMySqlEnabled: false
ipSecurityRestrictions: [
{
ipAddress: 'Any'
action: 'Allow'
priority: 1
name: 'Allow all'
description: 'Allow all access'
}
]
scmIpSecurityRestrictions: [
{
ipAddress: 'Any'
action: 'Allow'
priority: 1
name: 'Allow all'
description: 'Allow all access'
}
]
scmIpSecurityRestrictionsUseMain: false
http20Enabled: true
minTlsVersion: '1.2'
ftpsState: 'AllAllowed'
preWarmedInstanceCount: 0
}
}
// Function App Binding
resource functionAppBinding 'Microsoft.Web/sites/hostNameBindings@2020-06-01' = {
parent: functionApp
name: '${functionApp.name}.azurewebsites.net'
properties: {
siteName: functionApp.name
hostNameType: 'Verified'
}
}
resource keyvault 'Microsoft.KeyVault/vaults@2019-09-01' = {
name: vaultName
location: location
properties: {
tenantId: subscription().tenantId
sku: {
family: 'A'
name: 'standard'
}
accessPolicies: [
{
tenantId: subscription().tenantId
objectId: reference(functionApp.id, '2020-06-01', 'Full').identity.principalId // replace with your objectId
permissions: {
keys: [ ]
secrets: [
'get'
'list'
]
certificates: [ ]
}
}
]
enabledForDeployment: false
enabledForDiskEncryption: false
enabledForTemplateDeployment: false
softDeleteRetentionInDays: 90
enableRbacAuthorization: false
networkAcls: {
ipRules: []
virtualNetworkRules: []
}
}
}
// create secret
resource secret 'Microsoft.KeyVault/vaults/secrets@2018-02-14' = {
name: '${keyvault.name}/WATCHLIST-WORKSPACE-SHARED-KEY'
properties: {
value: workspaceSharedKey
}
}
resource secret1 'Microsoft.KeyVault/vaults/secrets@2018-02-14' = if (!empty(watchlistStorageAccountFileShareAccessKey)) {
name: '${keyvault.name}/WATCHLIST-STORAGE-ACCOUNT-FILE-SHARE-ACCESS-KEY'
properties: {
value: watchlistStorageAccountFileShareAccessKey
}
}
output functionAppName string = functionAppName
output functionPrincipalId string = reference(functionApp.id, '2020-06-01', 'Full').identity.principalId