-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.bicep
1411 lines (1331 loc) · 39.8 KB
/
deploy.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
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
param deployment_location string = resourceGroup().location
var unique_name = uniqueString(resourceGroup().id)
// MySQL Server
param mysql_server_name string = 'lstmnmysql'
param mysql_admin_user string = 'dbadmin'
param mysql_admin_pwd string
param mysql_privatelink_endpoint_name string = 'listmanmysqlpvt'
param privateDnsZones_privatelink_mysql_database_azure_com_name string = 'privatelink.mysql.database.azure.com'
// Cosmos DB
param comosdb_account_prefix string = 'lstmncos'
param cosmosdb_privatelink_endpoint_name string = 'listmancosmospvt'
param privateDnsZones_privatelink_documents_azure_com_name string = 'privatelink.documents.azure.com'
// Managed Service Identity (MSI)
param user_assigned_identity_prefix string = 'lstmnuser'
// Event Hub
param eventhub_namespace_prefix string = 'lstmnns'
// Key Vault
param key_vault_prefix string = 'lstkv'
// Azure Function
param azure_function_hosting_plan_name string = 'lstmnfunht'
param azure_function_name_prefix string = 'lmfunc'
// Storage Account
param storage_account_prefix string = 'lstfun'
// Virtual Network
param virtual_network_prefix string = 'lstmnpvtnt'
// Application Insights / Azure Monitor
param workspace_name string = 'lstmnworkspace'
param function_application_insights_prefix string = 'lstmnfuncai'
////////
// MYSQL
resource mysql_server 'Microsoft.DBforMySQL/servers@2017-12-01' = {
name: '${mysql_server_name}${unique_name}'
location: deployment_location
dependsOn:[
private_virtual_network
]
sku: {
name: 'GP_Gen5_2'
tier: 'GeneralPurpose'
family: 'Gen5'
capacity: 2
}
properties: {
createMode: 'Default'
administratorLogin: mysql_admin_user
administratorLoginPassword: mysql_admin_pwd
storageProfile: {
storageMB: 5120
backupRetentionDays: 7
geoRedundantBackup: 'Disabled'
storageAutogrow: 'Disabled'
}
version: '8.0'
sslEnforcement: 'Enabled'
minimalTlsVersion: 'TLSEnforcementDisabled'
infrastructureEncryption: 'Disabled'
publicNetworkAccess: 'Disabled'
}
}
////////
// COSMOS DB
// Cosmos Account
resource cosmosdb_account 'Microsoft.DocumentDB/databaseAccounts@2021-07-01-preview' = {
name: '${comosdb_account_prefix}${unique_name}'
location: deployment_location
dependsOn:[
private_virtual_network
]
kind: 'GlobalDocumentDB'
identity: {
type: 'None'
}
properties: {
publicNetworkAccess: 'Disabled'
enableAutomaticFailover: false
enableMultipleWriteLocations: false
isVirtualNetworkFilterEnabled: false
virtualNetworkRules: []
disableKeyBasedMetadataWriteAccess: false
enableFreeTier: false
enableAnalyticalStorage: false
analyticalStorageConfiguration: {
schemaType: 'WellDefined'
}
databaseAccountOfferType: 'Standard'
defaultIdentity: 'FirstPartyIdentity'
networkAclBypass: 'None'
disableLocalAuth: false
consistencyPolicy: {
defaultConsistencyLevel: 'Session'
maxIntervalInSeconds: 5
maxStalenessPrefix: 100
}
locations: [
{
locationName: deployment_location
failoverPriority: 0
isZoneRedundant: false
}
]
cors: []
capabilities: []
ipRules: []
backupPolicy: {
type: 'Periodic'
periodicModeProperties: {
backupIntervalInMinutes: 240
backupRetentionIntervalInHours: 8
backupStorageRedundancy: 'Local'
}
}
networkAclBypassResourceIds: []
diagnosticLogSettings: {
enableFullTextQuery: 'None'
}
createMode: 'Default'
}
}
// Cosmos Database
resource cosmosdb_account_database 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2021-07-01-preview' = {
parent: cosmosdb_account
name: 'listsample'
properties: {
resource: {
id: 'listsample'
}
options: {
throughput: 400
}
}
}
// Cosmos Container
resource cosmosdb_account_database_container 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers@2021-07-01-preview' = {
parent: cosmosdb_account_database
name: 'listsample'
properties: {
resource: {
id: 'listsample'
indexingPolicy: {
indexingMode: 'consistent'
automatic: true
includedPaths: [
{
path: '/*'
}
]
excludedPaths: [
{
path: '/"_etag"/?'
}
]
}
partitionKey: {
paths: [
'/id'
]
kind: 'Hash'
}
uniqueKeyPolicy: {
uniqueKeys: []
}
conflictResolutionPolicy: {
mode: 'LastWriterWins'
conflictResolutionPath: '/_ts'
}
}
}
dependsOn: [
cosmosdb_account_database
]
}
////////
// EVENT HUB
// Namespace definition
resource eventhub_namespace 'Microsoft.EventHub/namespaces@2021-06-01-preview' = {
name: '${eventhub_namespace_prefix}${unique_name}'
location: deployment_location
sku: {
name: 'Basic'
tier: 'Basic'
capacity: 1
}
properties: {
disableLocalAuth: false
zoneRedundant: false
isAutoInflateEnabled: false
maximumThroughputUnits: 0
kafkaEnabled: false
}
}
// Event Hub
resource eventhub_namespace_eventhub 'Microsoft.EventHub/namespaces/eventhubs@2021-06-01-preview' = {
parent: eventhub_namespace
name: 'clientevents'
properties: {
messageRetentionInDays: 1
partitionCount: 2
}
}
// Event Hub Authorisation Rules (one to send events, one to receive)
resource eventhub_namespace_eventhub_recieveevents_rule 'Microsoft.EventHub/namespaces/eventhubs/authorizationRules@2021-06-01-preview' = {
parent: eventhub_namespace_eventhub
name: 'ReceiveEvents'
properties: {
rights: [
'Listen'
]
}
}
resource eventhub_namespace_eventhub_sendevents_rule 'Microsoft.EventHub/namespaces/eventhubs/authorizationRules@2021-06-01-preview' = {
parent: eventhub_namespace_eventhub
name: 'SendEvents'
properties: {
rights: [
'Send'
]
}
}
////////
// User-Assigned Managed Service Identity
resource function_keyvault_identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = {
name: '${user_assigned_identity_prefix}${unique_name}'
location: deployment_location
}
////////
// NETWORKING
// Virtual Network
resource private_virtual_network 'Microsoft.Network/virtualNetworks@2020-11-01' = {
name: '${virtual_network_prefix}${unique_name}'
location: deployment_location
properties: {
addressSpace: {
addressPrefixes: [
'172.17.0.0/16'
]
}
subnets: [
{
name: 'default'
properties: {
addressPrefix: '172.17.0.0/24'
serviceEndpoints: []
delegations: []
privateEndpointNetworkPolicies: 'Enabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
{
name: 'keyvaultsubnet'
properties: {
addressPrefix: '172.17.2.0/24'
serviceEndpoints: [
{
service: 'Microsoft.KeyVault'
locations: [
'*'
]
}
]
delegations: []
privateEndpointNetworkPolicies: 'Enabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
{
name: 'functionssubnet'
properties: {
addressPrefix: '172.17.4.0/24'
serviceEndpoints: [
{
service: 'Microsoft.Web'
locations: [
'*'
]
}
{
service: 'Microsoft.KeyVault'
locations: [
'*'
]
}
]
delegations: [
{
name: 'Microsoft.Web.serverFarms'
properties: {
serviceName: 'Microsoft.Web/serverFarms'
}
}
]
privateEndpointNetworkPolicies: 'Enabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
{
name: 'databasesubnet'
properties: {
addressPrefix: '172.17.1.0/24'
serviceEndpoints: []
delegations: []
privateEndpointNetworkPolicies: 'Disabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
]
virtualNetworkPeerings: []
enableDdosProtection: false
}
}
// Virtual Network Subnets
resource private_virtual_network_default_subnet 'Microsoft.Network/virtualNetworks/subnets@2020-11-01' = {
parent: private_virtual_network
name: 'default'
properties: {
addressPrefix: '172.17.0.0/24'
serviceEndpoints: []
delegations: []
privateEndpointNetworkPolicies: 'Enabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
resource private_virtual_network_functions_subnet 'Microsoft.Network/virtualNetworks/subnets@2020-11-01' = {
parent: private_virtual_network
name: 'functionssubnet'
properties: {
addressPrefix: '172.17.4.0/24'
serviceEndpoints: [
{
service: 'Microsoft.Web'
locations: [
'*'
]
}
{
service: 'Microsoft.KeyVault'
locations: [
'*'
]
}
]
delegations: [
{
name: 'Microsoft.Web.serverFarms'
properties: {
serviceName: 'Microsoft.Web/serverFarms'
}
}
]
privateEndpointNetworkPolicies: 'Enabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
resource private_virtual_network_keyvault_subnet 'Microsoft.Network/virtualNetworks/subnets@2020-11-01' = {
parent: private_virtual_network
name: 'keyvaultsubnet'
properties: {
addressPrefix: '172.17.2.0/24'
serviceEndpoints: [
{
service: 'Microsoft.KeyVault'
locations: [
'*'
]
}
]
delegations: []
privateEndpointNetworkPolicies: 'Enabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
resource private_virtual_network_nosql_subnet 'Microsoft.Network/virtualNetworks/subnets@2020-11-01' = {
parent: private_virtual_network
name: 'nosqlsubnet'
properties: {
addressPrefix: '172.17.3.0/24'
serviceEndpoints: []
delegations: []
privateEndpointNetworkPolicies: 'Disabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
resource private_virtual_network_database_subnet 'Microsoft.Network/virtualNetworks/subnets@2020-11-01' = {
parent: private_virtual_network
name: 'databasesubnet'
properties: {
addressPrefix: '172.17.1.0/24'
serviceEndpoints: []
delegations: []
privateEndpointNetworkPolicies: 'Disabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
// Private DNS
resource privateDnsZones_privatelink_documents_azure_com_name_resource 'Microsoft.Network/privateDnsZones@2018-09-01' = {
name: privateDnsZones_privatelink_documents_azure_com_name
location: 'global'
}
resource privateDnsZones_privatelink_mysql_database_azure_com_name_resource 'Microsoft.Network/privateDnsZones@2018-09-01' = {
name: privateDnsZones_privatelink_mysql_database_azure_com_name
location: 'global'
}
resource privateDnsZones_privatelink_documents_azure_com_name_listmancosmos 'Microsoft.Network/privateDnsZones/A@2018-09-01' = {
parent: privateDnsZones_privatelink_documents_azure_com_name_resource
name: 'listmancosmos'
properties: {
ttl: 10
aRecords: [
{
ipv4Address: '172.17.3.4'
}
]
}
}
resource privateDnsZones_privatelink_documents_azure_com_name_listmancosmos_westus2 'Microsoft.Network/privateDnsZones/A@2018-09-01' = {
parent: privateDnsZones_privatelink_documents_azure_com_name_resource
name: 'listmancosmos-westus2'
properties: {
ttl: 10
aRecords: [
{
ipv4Address: '172.17.3.5'
}
]
}
}
resource privateDnsZones_privatelink_mysql_database_azure_com_name_listmanmysql 'Microsoft.Network/privateDnsZones/A@2018-09-01' = {
parent: privateDnsZones_privatelink_mysql_database_azure_com_name_resource
name: 'listmanmysql'
properties: {
ttl: 10
aRecords: [
{
ipv4Address: '172.17.1.4'
}
]
}
}
resource Microsoft_Network_privateDnsZones_SOA_privateDnsZones_privatelink_documents_azure_com_name 'Microsoft.Network/privateDnsZones/SOA@2018-09-01' = {
parent: privateDnsZones_privatelink_documents_azure_com_name_resource
name: '@'
properties: {
ttl: 3600
soaRecord: {
email: 'azureprivatedns-host.microsoft.com'
expireTime: 2419200
host: 'azureprivatedns.net'
minimumTtl: 10
refreshTime: 3600
retryTime: 300
serialNumber: 1
}
}
}
resource Microsoft_Network_privateDnsZones_SOA_privateDnsZones_privatelink_mysql_database_azure_com_name 'Microsoft.Network/privateDnsZones/SOA@2018-09-01' = {
parent: privateDnsZones_privatelink_mysql_database_azure_com_name_resource
name: '@'
properties: {
ttl: 3600
soaRecord: {
email: 'azureprivatedns-host.microsoft.com'
expireTime: 2419200
host: 'azureprivatedns.net'
minimumTtl: 10
refreshTime: 3600
retryTime: 300
serialNumber: 1
}
}
}
// Cosmos DB private DNS link to VNet
resource private_dns_cosmos_private_network_registration 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2018-09-01' = {
parent: privateDnsZones_privatelink_documents_azure_com_name_resource
name: 'cosmospvtdns'
location: 'global'
dependsOn:[
private_virtual_network
]
properties: {
registrationEnabled: false
virtualNetwork: {
id: private_virtual_network.id
}
}
}
// MySQL private DNS link to VNet
resource private_dns_mysql_private_network_registration 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2018-09-01' = {
parent: privateDnsZones_privatelink_mysql_database_azure_com_name_resource
name: 'mysqlpvtdns'
location: 'global'
dependsOn:[
private_virtual_network
]
properties: {
registrationEnabled: false
virtualNetwork: {
id: private_virtual_network.id
}
}
}
resource cosmosdb_privatelink_endpoint 'Microsoft.Network/privateEndpoints@2020-11-01' = {
name: cosmosdb_privatelink_endpoint_name
location: deployment_location
properties: {
privateLinkServiceConnections: [
{
name: cosmosdb_privatelink_endpoint_name
properties: {
privateLinkServiceId: cosmosdb_account.id
groupIds: [
'Sql'
]
privateLinkServiceConnectionState: {
status: 'Approved'
actionsRequired: 'None'
}
}
}
]
manualPrivateLinkServiceConnections: []
subnet: {
id: private_virtual_network_nosql_subnet.id
}
customDnsConfigs: []
}
}
resource mysql_privatelink_endpoint 'Microsoft.Network/privateEndpoints@2020-11-01' = {
name: mysql_privatelink_endpoint_name
location: deployment_location
properties: {
privateLinkServiceConnections: [
{
name: mysql_privatelink_endpoint_name
properties: {
privateLinkServiceId: mysql_server.id
groupIds: [
'mysqlServer'
]
privateLinkServiceConnectionState: {
status: 'Approved'
description: 'Auto-approved'
actionsRequired: 'None'
}
}
}
]
manualPrivateLinkServiceConnections: []
subnet: {
id: private_virtual_network_database_subnet.id
}
customDnsConfigs: []
}
}
resource privateEndpoints_listmancosmospvt_name_default 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2020-11-01' = {
parent: cosmosdb_privatelink_endpoint
name: 'default'
properties: {
privateDnsZoneConfigs: [
{
name: 'privatelink-documents-azure-com'
properties: {
privateDnsZoneId: privateDnsZones_privatelink_documents_azure_com_name_resource.id
}
}
]
}
}
resource privateEndpoints_listmanmysqlpvt_name_default 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups@2020-11-01' = {
parent: mysql_privatelink_endpoint
name: 'default'
properties: {
privateDnsZoneConfigs: [
{
name: 'privatelink-mysql-database-azure-com'
properties: {
privateDnsZoneId: privateDnsZones_privatelink_mysql_database_azure_com_name_resource.id
}
}
]
}
}
//////
// STORAGE ACCOUNT
resource storage_account_functions 'Microsoft.Storage/storageAccounts@2021-06-01' = {
name: '${storage_account_prefix}${unique_name}'
location: deployment_location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
defaultToOAuthAuthentication: false
allowCrossTenantReplication: true
minimumTlsVersion: 'TLS1_2'
allowBlobPublicAccess: true
allowSharedKeyAccess: true
networkAcls: {
bypass: 'AzureServices'
virtualNetworkRules: []
ipRules: []
defaultAction: 'Allow'
}
supportsHttpsTrafficOnly: true
encryption: {
services: {
file: {
keyType: 'Account'
enabled: true
}
blob: {
keyType: 'Account'
enabled: true
}
}
keySource: 'Microsoft.Storage'
}
accessTier: 'Hot'
}
}
// Blob Service configuration
resource storage_account_functions_blob_default 'Microsoft.Storage/storageAccounts/blobServices@2021-06-01' = {
parent: storage_account_functions
name: 'default'
properties: {
changeFeed: {
enabled: false
}
restorePolicy: {
enabled: false
}
containerDeleteRetentionPolicy: {
enabled: true
days: 7
}
cors: {
corsRules: []
}
deleteRetentionPolicy: {
enabled: true
days: 7
}
isVersioningEnabled: false
}
}
// Blob Service Containers (folders)
resource storageAccounts_listmanfuncstore_name_default_azure_webjobs_eventhub 'Microsoft.Storage/storageAccounts/blobServices/containers@2021-06-01' = {
parent: storage_account_functions_blob_default
name: 'azure-webjobs-eventhub'
properties: {
immutableStorageWithVersioning: {
enabled: false
}
defaultEncryptionScope: '$account-encryption-key'
denyEncryptionScopeOverride: false
publicAccess: 'None'
}
dependsOn: [
storage_account_functions
]
}
resource storageAccounts_listmanfuncstore_name_default_azure_webjobs_hosts 'Microsoft.Storage/storageAccounts/blobServices/containers@2021-06-01' = {
parent: storage_account_functions_blob_default
name: 'azure-webjobs-hosts'
properties: {
immutableStorageWithVersioning: {
enabled: false
}
defaultEncryptionScope: '$account-encryption-key'
denyEncryptionScopeOverride: false
publicAccess: 'None'
}
dependsOn: [
storage_account_functions
]
}
resource storageAccounts_listmanfuncstore_name_default_azure_webjobs_secrets 'Microsoft.Storage/storageAccounts/blobServices/containers@2021-06-01' = {
parent: storage_account_functions_blob_default
name: 'azure-webjobs-secrets'
properties: {
immutableStorageWithVersioning: {
enabled: false
}
defaultEncryptionScope: '$account-encryption-key'
denyEncryptionScopeOverride: false
publicAccess: 'None'
}
dependsOn: [
storage_account_functions
]
}
//////
// AZURE FUNCTION
// Hosting Plan
resource azure_function_hosting_plan 'Microsoft.Web/serverfarms@2021-02-01' = {
name: '${azure_function_hosting_plan_name}${unique_name}'
location: deployment_location
dependsOn:[
private_virtual_network
]
sku: {
name: 'S1'
tier: 'Standard'
size: 'S1'
family: 'S'
capacity: 1
}
kind: 'linux'
properties: {
perSiteScaling: false
elasticScaleEnabled: false
maximumElasticWorkerCount: 1
isSpot: false
reserved: true
isXenon: false
hyperV: false
targetWorkerCount: 0
targetWorkerSizeId: 0
zoneRedundant: false
}
}
// Function App
resource azure_function 'Microsoft.Web/sites@2021-02-01' = {
name: '${azure_function_name_prefix}${unique_name}'
location: deployment_location
dependsOn:[
private_virtual_network_functions_subnet
function_keyvault_identity
azure_function_hosting_plan
]
kind: 'functionapp,linux'
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${function_keyvault_identity.id}': {}
}
}
properties: {
enabled: true
hostNameSslStates: [
{
name: '${azure_function_name_prefix}${unique_name}.azurewebsites.net'
sslState: 'IpBasedEnabled'
hostType: 'Standard'
}
{
name: '$${azure_function_name_prefix}${unique_name}.scm.azurewebsites.net'
sslState: 'IpBasedEnabled'
hostType: 'Repository'
}
]
serverFarmId: azure_function_hosting_plan.id
reserved: true
isXenon: false
hyperV: false
siteConfig: {
numberOfWorkers: 1
linuxFxVersion: 'NODE|14'
acrUseManagedIdentityCreds: false
alwaysOn: true
http20Enabled: false
functionAppScaleLimit: 0
minimumElasticInstanceCount: 1
}
scmSiteAlsoStopped: false
clientAffinityEnabled: false
clientCertEnabled: false
clientCertMode: 'Required'
hostNamesDisabled: false
containerSize: 1536
dailyMemoryTimeQuota: 0
httpsOnly: true
redundancyMode: 'None'
storageAccountRequired: false
virtualNetworkSubnetId: private_virtual_network_functions_subnet.id
keyVaultReferenceIdentity: function_keyvault_identity.id
}
}
// Virtual network configuration for Function
resource azure_function_network_connection 'Microsoft.Web/sites/virtualNetworkConnections@2021-02-01' = {
parent: azure_function
name: 'functionssubnet'
properties: {
vnetResourceId: private_virtual_network_functions_subnet.id
isSwift: true
}
dependsOn:[
private_virtual_network_functions_subnet
]
}
// Function App Configuration
resource azure_function_configuration 'Microsoft.Web/sites/config@2021-02-01' = {
parent: azure_function
dependsOn:[
function_keyvault_identity
private_virtual_network_functions_subnet
function_application_insights
storage_account_functions
keyvault_secret_cosmosdb_connection
keyvault_secret_eventhub_connection
keyvault_secret_mysql_user
keyvault_secret_mysql_pwd
keyvault_secret_mysql_hostname
]
name: 'web'
properties: {
numberOfWorkers: 1
defaultDocuments: [
'Default.htm'
'Default.html'
'Default.asp'
'index.htm'
'index.html'
'iisstart.htm'
'default.aspx'
'index.php'
]
netFrameworkVersion: 'v4.0'
linuxFxVersion: 'NODE|14'
requestTracingEnabled: false
remoteDebuggingEnabled: false
remoteDebuggingVersion: 'VS2019'
httpLoggingEnabled: false
acrUseManagedIdentityCreds: false
logsDirectorySizeLimit: 35
detailedErrorLoggingEnabled: false
use32BitWorkerProcess: false
webSocketsEnabled: false
appSettings: [
{
name: 'AzureWebJobsStorage'
value: 'DefaultEndpointsProtocol=https;AccountName=${storage_account_functions.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storage_account_functions.listKeys().keys[0].value}'
}
{
name: 'FUNCTIONS_EXTENSION_VERSION'
value: '~4'
}
{
name: 'FUNCTIONS_WORKER_RUNTIME'
value: 'node'
}
{
name: 'COSMOS_DATABASE'
value: 'listsample'
}
{
name: 'COSMOS_CONTAINER'
value: 'listsample'
}
{
name: 'DATABASE_NAME'
value: 'lambdademo'
}
{
name: 'WEBSITE_DNS_SERVER'
value: '168.63.129.16'
}
{
name: 'WEBSITE_VNET_ROUTE_ALL'
value: '1'
}
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: function_application_insights.properties.InstrumentationKey
}
{
name: 'COSMOS_CONNECTION'
value: '@Microsoft.KeyVault(SecretUri=${keyvault_secret_cosmosdb_connection.properties.secretUri})'
}
{
name: 'SAMPLE_EVENT_HUB'
value: '@Microsoft.KeyVault(SecretUri=${keyvault_secret_eventhub_connection.properties.secretUri})'
}
{
name: 'DATABASE_USER'
value: '@Microsoft.KeyVault(SecretUri=${keyvault_secret_mysql_user.properties.secretUri})'
}
{
name: 'DATABASE_PWD'
value: '@Microsoft.KeyVault(SecretUri=${keyvault_secret_mysql_pwd.properties.secretUri})'
}
{
name: 'DATABASE_HOST'
value: '@Microsoft.KeyVault(SecretUri=${keyvault_secret_mysql_hostname.properties.secretUri})'
}
]
alwaysOn: true
managedPipelineMode: 'Integrated'
virtualApplications: [
{
virtualPath: '/'
physicalPath: 'site\\wwwroot'
preloadEnabled: true
}
]
loadBalancing: 'LeastRequests'
experiments: {
rampUpRules: []
}
autoHealEnabled: false
vnetName: private_virtual_network_functions_subnet.name
vnetRouteAllEnabled: true
localMySqlEnabled: false
keyVaultReferenceIdentity: function_keyvault_identity.id
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: false
minTlsVersion: '1.2'
scmMinTlsVersion: '1.0'
ftpsState: 'Disabled'
preWarmedInstanceCount: 0
functionAppScaleLimit: 0
functionsRuntimeScaleMonitoringEnabled: false
minimumElasticInstanceCount: 1
azureStorageAccounts: {}
}
}
//////
// KEY VAULT
resource listman_keyvault 'Microsoft.KeyVault/vaults@2021-06-01-preview' = {
name: '${key_vault_prefix}${unique_name}'
location: deployment_location
dependsOn:[
function_keyvault_identity
private_virtual_network
]
properties: {