@@ -127,6 +127,10 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2021-08-01' = {
127
127
}
128
128
}
129
129
130
+ resource fileShare 'Microsoft.Storage/storageAccounts/fileServices/shares@2022-09-01' = if (EnablePrivateNetworking != true || EnableElasticPremiumPlan == true ) {
131
+ name : '${storageAccount .name }/default/${toLower (FunctionAppName )}'
132
+ }
133
+
130
134
resource queue 'Microsoft.Storage/storageAccounts/queueServices/queues@2022-09-01' = {
131
135
name : '${storageAccount .name }/default/dlpqueue'
132
136
}
@@ -307,29 +311,70 @@ var appSettingsFiles = [
307
311
name : 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'
308
312
value : 'DefaultEndpointsProtocol=https;AccountName=${StorageAccountName };EndpointSuffix=${environment ().suffixes .storage };AccountKey=${storageAccount .listKeys ().keys [0 ].value }'
309
313
}
314
+ {
315
+ name : 'WEBSITE_CONTENTSHARE'
316
+ value : toLower (FunctionAppName )
317
+ }
310
318
]
311
319
312
320
var appSettingsFilesKv = [
313
321
{
314
322
name : 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'
315
323
value : '@Microsoft.KeyVault(VaultName=${KeyVaultName };SecretName=StorageAccountConnectionString)'
316
324
}
325
+ {
326
+ name : 'WEBSITE_CONTENTSHARE'
327
+ value : toLower (FunctionAppName )
328
+ }
317
329
]
318
330
319
- module functionAppDeploy 'modules/functionApp.bicep' = {
320
- name : 'functionAppDeploy'
321
- params : {
322
- AppSettings : concat (appSettingsDefault , EnablePrivateNetworking != true || EnableElasticPremiumPlan == true ? appSettingsFiles : [])
323
- EnablePrivateNetworking : EnablePrivateNetworking
324
- FunctionAppName : FunctionAppName
325
- FunctionAppSubnetId : EnablePrivateNetworking == true ? privateNetwork .outputs .functionAppSubnetId : ''
326
- HostingPlanId : hostingPlan .id
327
- Location : location
328
- UserAssignedMiId : userAssignedMi .id
329
- DeployFunctionCode : DeployFunctionCode
330
- UserAssignedMiPrincipalId : userAssignedMi .properties .principalId
331
- RoleIdOwner : roleIdOwner
332
- AlwaysOn : EnablePrivateNetworking != true || EnableElasticPremiumPlan == true ? false : true
331
+ resource functionApp 'Microsoft.Web/sites@2024-04-01' = {
332
+ name : FunctionAppName
333
+ location : location
334
+ identity : {
335
+ type : 'UserAssigned'
336
+ userAssignedIdentities : {
337
+ '${userAssignedMi .id }' : {}
338
+ }
339
+ }
340
+ kind : 'functionapp'
341
+ properties : {
342
+ serverFarmId : hostingPlan .id
343
+ keyVaultReferenceIdentity : userAssignedMi .id
344
+ httpsOnly : true
345
+ clientCertEnabled : true
346
+ clientCertMode : 'OptionalInteractiveUser'
347
+ virtualNetworkSubnetId : EnablePrivateNetworking == true ? privateNetwork .outputs .functionAppSubnetId : (null )
348
+ vnetContentShareEnabled : EnablePrivateNetworking == true ? true : false
349
+ vnetRouteAllEnabled : EnablePrivateNetworking == true ? true : false
350
+ siteConfig : {
351
+ appSettings : concat (appSettingsDefault , EnablePrivateNetworking != true || EnableElasticPremiumPlan == true ? appSettingsFiles : [])
352
+ powerShellVersion : '7.4'
353
+ minTlsVersion : '1.2'
354
+ ftpsState : 'Disabled'
355
+ http20Enabled : true
356
+ alwaysOn : EnablePrivateNetworking != true || EnableElasticPremiumPlan == true ? false : true
357
+ publicNetworkAccess : 'Enabled'
358
+ cors : {
359
+ allowedOrigins : [
360
+ 'https://portal.azure.com'
361
+ ]
362
+ }
363
+ }
364
+ }
365
+ dependsOn : [
366
+ fileShare
367
+ queue
368
+ ]
369
+ }
370
+
371
+ resource roleAssignmentFa 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (DeployFunctionCode == true ) {
372
+ name : guid (subscription ().id , resourceGroup ().id , userAssignedMi .id )
373
+ scope : functionApp
374
+ properties : {
375
+ principalId : userAssignedMi .properties .principalId
376
+ roleDefinitionId : roleIdOwner
377
+ principalType : 'ServicePrincipal'
333
378
}
334
379
}
335
380
@@ -343,13 +388,10 @@ module functionAppDeployFilesKv 'modules/functionApp.bicep' = if(EnablePrivateNe
343
388
HostingPlanId : hostingPlan .id
344
389
Location : location
345
390
UserAssignedMiId : userAssignedMi .id
346
- DeployFunctionCode : DeployFunctionCode
347
- UserAssignedMiPrincipalId : userAssignedMi .properties .principalId
348
- RoleIdOwner : roleIdOwner
349
391
AlwaysOn : false
350
392
}
351
393
dependsOn : [
352
- functionAppDeploy
394
+ functionApp
353
395
]
354
396
}
355
397
@@ -393,7 +435,7 @@ module sentinelRules 'modules/sentinelRules.bicep' = if (DeployAnalyticsRules ==
393
435
scope : resourceGroup (split (law .id , '/' )[2 ], split (law .id , '/' )[4 ])
394
436
dependsOn : [
395
437
createCustomTables
396
- functionAppDeploy
438
+ functionApp
397
439
purviewDLPFunction
398
440
]
399
441
params : {
@@ -407,7 +449,7 @@ module sentinelWorkbooks 'modules/sentinelWorkbooks.bicep' = if(DeployWorkbooks
407
449
scope : resourceGroup (split (law .id , '/' )[2 ], split (law .id , '/' )[4 ])
408
450
dependsOn : [
409
451
createCustomTables
410
- functionAppDeploy
452
+ functionApp
411
453
]
412
454
params : {
413
455
workbookSourceId : law .id
@@ -429,6 +471,7 @@ module privateNetwork 'modules/privateNetwork.bicep' = if(EnablePrivateNetworkin
429
471
PrivateEndpointsSubnet : PrivateEndpointsSubnet
430
472
PrincipalId : userAssignedMi .properties .principalId
431
473
DeployCode : DeployFunctionCode
474
+ EnableElasticPremiumPlan : EnableElasticPremiumPlan
432
475
}
433
476
}
434
477
@@ -437,7 +480,7 @@ module functionAppPe 'modules/functionAppPE.bicep' = if(EnablePrivateNetworking
437
480
name : 'functionAppPe'
438
481
params : {
439
482
location : location
440
- FunctionAppId : functionAppDeploy . outputs . functionAppId
483
+ FunctionAppId : functionApp . id
441
484
FunctionAppName : FunctionAppName
442
485
PrivateEndpointSubnetId : EnablePrivateNetworking == true ? privateNetwork .outputs .privateEndpointSubnetId : (null )
443
486
VnetId : EnablePrivateNetworking == true ? privateNetwork .outputs .vnetId : (null )
@@ -476,8 +519,8 @@ resource deploymentScript 'Microsoft.Resources/deploymentScripts@2023-08-01' = i
476
519
]
477
520
primaryScriptUri : deploymentScriptUri
478
521
arguments : EnablePrivateNetworking == true
479
- ? '-PackageUri ${functionAppPackageUri } -SubscriptionId ${split (subscription ().id , '/' )[2 ]} -ResourceGroupName ${resourceGroup ().name } -FunctionAppName ${functionAppPe .outputs .functionAppName } -FAScope ${functionAppDeploy . outputs . functionAppId } -UAMIPrincipalId ${userAssignedMi .properties .principalId } -VnetScope ${privateNetwork .outputs .vnetId } -RestrictedIPs "None"'
480
- : '-PackageUri ${functionAppPackageUri } -SubscriptionId ${split (subscription ().id , '/' )[2 ]} -ResourceGroupName ${resourceGroup ().name } -FunctionAppName ${functionAppDeploy . outputs . functionAppName } -FAScope ${functionAppDeploy . outputs . functionAppId } -UAMIPrincipalId ${userAssignedMi .properties .principalId }'
522
+ ? '-PackageUri ${functionAppPackageUri } -SubscriptionId ${split (subscription ().id , '/' )[2 ]} -ResourceGroupName ${resourceGroup ().name } -FunctionAppName ${functionAppPe .outputs .functionAppName } -FAScope ${functionApp . id } -UAMIPrincipalId ${userAssignedMi .properties .principalId } -VnetScope ${privateNetwork .outputs .vnetId } -RestrictedIPs "None"'
523
+ : '-PackageUri ${functionAppPackageUri } -SubscriptionId ${split (subscription ().id , '/' )[2 ]} -ResourceGroupName ${resourceGroup ().name } -FunctionAppName ${FunctionAppName } -FAScope ${functionApp . id } -UAMIPrincipalId ${userAssignedMi .properties .principalId }'
481
524
}
482
525
dependsOn : EnablePrivateNetworking != true || EnableElasticPremiumPlan == true ? [
483
526
functionAppDeployFilesKv
0 commit comments