-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathmain.bicep
1745 lines (1561 loc) · 72.3 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
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
targetScope = 'subscription'
/////////////////////////////////////////////////////////////////////////////
// TEMPLATE SETTINGS (PARAMETERS and VARIABLES)
/////////////////////////////////////////////////////////////////////////////
// Parameters Note:
// Use the file 'main.parameters.json' to set the parameter values.
// 'main.parameters.json', map the parameters to environment variables using the "${ENV_VAR_NAME}" notation.
// If you want to set the value of any of those variables, just run the following command: azd env set ENV_VAR_NAME value.
// The value of 'ENV_VAR_NAME' will be automatically fetched if you deploy the template using 'azd'.
// Templates Reference: https://learn.microsoft.com/en-us/azure/templates/
// Environment name. This is automatically set by the 'azd' tool.
@description('Environment name used as a tag for all resources. This is directly mapped to the azd-environment.')
param environmentName string = ''
// Location. This is automatically set by the 'azd' tool.
@description('Primary location for all resources.')
param location string = ''
// Resource group
@description('Name of the resource group where all resources will be created. When empty, the name is autogenerated.')
param resourceGroupName string = ''
var _resourceGroupName = !empty(resourceGroupName) ? resourceGroupName : 'rg-${environmentName}'
// Tag settings
// default required tags for azd deployment
var azdTags = { 'azd-env-name': environmentName }
@description('Key-value pairs of tags to assign to all resources. The default azd tags are automatically added.')
param deploymentTags object
var tags = union(azdTags, deploymentTags)
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: _resourceGroupName
location: location
tags: tags
}
// unique hash based on the subcription id, environment name and location. The hash is used to generate unique names for resources.
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
// Disable load testing?
@description('Disable load testing? If yes it will not create load testing resource.')
@allowed([true, false])
param provisionLoadTesting bool = false
var _provisionLoadTesting = provisionLoadTesting
// Reuse preexisting resources settings
@description('Settings to define reusable resources.')
var _azureReuseConfigDefaults = {
aoaiReuse: false
existingAoaiResourceGroupName: ''
existingAoaiName: ''
appInsightsReuse: false
existingAppInsightsResourceGroupName: ''
existingAppInsightsName: ''
appServicePlanReuse: false
existingAppServicePlanResourceGroupName: ''
existingAppServicePlanName: ''
aiSearchReuse: false
existingAiSearchResourceGroupName: ''
existingAiSearchName: ''
aiServicesReuse: false
existingAiServicesResourceGroupName: ''
existingAiServicesName: ''
cosmosDbReuse: false
existingCosmosDbResourceGroupName: ''
existingCosmosDbAccountName: ''
existingCosmosDbDatabaseName : ''
keyVaultReuse: false
existingKeyVaultResourceGroupName: ''
existingKeyVaultName: ''
storageReuse: false
existingStorageResourceGroupName: ''
existingStorageName: ''
vnetReuse: false
existingVnetResourceGroupName: ''
existingVnetName: ''
orchestratorFunctionAppReuse: false
existingOrchestratorFunctionAppResourceGroupName: ''
existingOrchestratorFunctionAppName: ''
dataIngestionFunctionAppReuse: false
existingDataIngestionFunctionAppResourceGroupName: ''
existingDataIngestionFunctionAppName: ''
appServiceReuse: false
existingAppServiceName: ''
existingAppServiceNameResourceGroupName: ''
orchestratorFunctionAppStorageReuse: false
existingOrchestratorFunctionAppStorageName: ''
existingOrchestratorFunctionAppStorageResourceGroupName: ''
dataIngestionFunctionAppStorageReuse: false
existingDataIngestionFunctionAppStorageName: ''
existingDataIngestionFunctionAppStorageResourceGroupName: ''
}
param azureReuseConfig object = {}
var _azureReuseConfig = union(_azureReuseConfigDefaults, {
aoaiReuse: (empty(azureReuseConfig.aoaiReuse) ? _azureReuseConfigDefaults.aoaiReuse : toLower(azureReuseConfig.aoaiReuse) == 'true')
existingAoaiResourceGroupName: (empty(azureReuseConfig.existingAoaiResourceGroupName) ? _azureReuseConfigDefaults.existingAoaiResourceGroupName : azureReuseConfig.existingAoaiResourceGroupName)
existingAoaiName: (empty(azureReuseConfig.existingAoaiName) ? _azureReuseConfigDefaults.existingAoaiName : azureReuseConfig.existingAoaiName)
aiServicesReuse: (empty(azureReuseConfig.aiServicesReuse) ? _azureReuseConfigDefaults.aiServicesReuse : toLower(azureReuseConfig.aiServicesReuse) == 'true')
existingAiServicesResourceGroupName: (empty(azureReuseConfig.existingAiServicesResourceGroupName) ? _azureReuseConfigDefaults.existingAiServicesResourceGroupName : azureReuseConfig.existingAiServicesResourceGroupName)
existingAiServicesName: (empty(azureReuseConfig.existingAiServicesName) ? _azureReuseConfigDefaults.existingAiServicesName : azureReuseConfig.existingAiServicesName)
appInsightsReuse: (empty(azureReuseConfig.appInsightsReuse) ? _azureReuseConfigDefaults.appInsightsReuse : toLower(azureReuseConfig.appInsightsReuse) == 'true')
existingAppInsightsResourceGroupName: (empty(azureReuseConfig.existingAppInsightsResourceGroupName) ? _azureReuseConfigDefaults.existingAppInsightsResourceGroupName : azureReuseConfig.existingAppInsightsResourceGroupName)
existingAppInsightsName: (empty(azureReuseConfig.existingAppInsightsName) ? _azureReuseConfigDefaults.existingAppInsightsName : azureReuseConfig.existingAppInsightsName)
appServicePlanReuse: (empty(azureReuseConfig.appServicePlanReuse) ? _azureReuseConfigDefaults.appServicePlanReuse : toLower(azureReuseConfig.appServicePlanReuse) == 'true')
existingAppServicePlanResourceGroupName: (empty(azureReuseConfig.existingAppServicePlanResourceGroupName) ? _azureReuseConfigDefaults.existingAppServicePlanResourceGroupName : azureReuseConfig.existingAppServicePlanResourceGroupName)
existingAppServicePlanName: (empty(azureReuseConfig.existingAppServicePlanName) ? _azureReuseConfigDefaults.existingAppServicePlanName : azureReuseConfig.existingAppServicePlanName)
aiSearchReuse: (empty(azureReuseConfig.aiSearchReuse) ? _azureReuseConfigDefaults.aiSearchReuse : toLower(azureReuseConfig.aiSearchReuse) == 'true')
existingAiSearchResourceGroupName: (empty(azureReuseConfig.existingAiSearchResourceGroupName) ? _azureReuseConfigDefaults.existingAiSearchResourceGroupName : azureReuseConfig.existingAiSearchResourceGroupName)
existingAiSearchName: (empty(azureReuseConfig.existingAiSearchName) ? _azureReuseConfigDefaults.existingAiSearchName : azureReuseConfig.existingAiSearchName)
cosmosDbReuse: (empty(azureReuseConfig.cosmosDbReuse) ? _azureReuseConfigDefaults.cosmosDbReuse : toLower(azureReuseConfig.cosmosDbReuse) == 'true')
existingCosmosDbResourceGroupName: (empty(azureReuseConfig.existingCosmosDbResourceGroupName) ? _azureReuseConfigDefaults.existingCosmosDbResourceGroupName : azureReuseConfig.existingCosmosDbResourceGroupName)
existingCosmosDbAccountName: (empty(azureReuseConfig.existingCosmosDbAccountName) ? _azureReuseConfigDefaults.existingCosmosDbAccountName : azureReuseConfig.existingCosmosDbAccountName)
existingCosmosDbDatabaseName: (empty(azureReuseConfig.existingCosmosDbDatabaseName) ? _azureReuseConfigDefaults.existingCosmosDbDatabaseName : azureReuseConfig.existingCosmosDbDatabaseName)
keyVaultReuse: (empty(azureReuseConfig.keyVaultReuse) ? _azureReuseConfigDefaults.keyVaultReuse : toLower(azureReuseConfig.keyVaultReuse) == 'true')
existingKeyVaultResourceGroupName: (empty(azureReuseConfig.existingKeyVaultResourceGroupName) ? _azureReuseConfigDefaults.existingKeyVaultResourceGroupName : azureReuseConfig.existingKeyVaultResourceGroupName)
existingKeyVaultName: (empty(azureReuseConfig.existingKeyVaultName) ? _azureReuseConfigDefaults.existingKeyVaultName : azureReuseConfig.existingKeyVaultName)
storageReuse: (empty(azureReuseConfig.storageReuse) ? _azureReuseConfigDefaults.storageReuse : toLower(azureReuseConfig.storageReuse) == 'true')
existingStorageResourceGroupName: (empty(azureReuseConfig.existingStorageResourceGroupName) ? _azureReuseConfigDefaults.existingStorageResourceGroupName : azureReuseConfig.existingStorageResourceGroupName)
existingStorageName: (empty(azureReuseConfig.existingStorageName) ? _azureReuseConfigDefaults.existingStorageName : azureReuseConfig.existingStorageName)
vnetReuse: (empty(azureReuseConfig.vnetReuse) ? _azureReuseConfigDefaults.vnetReuse : toLower(azureReuseConfig.vnetReuse) == 'true')
existingVnetResourceGroupName: (empty(azureReuseConfig.existingVnetResourceGroupName) ? _azureReuseConfigDefaults.existingVnetResourceGroupName : azureReuseConfig.existingVnetResourceGroupName)
existingVnetName: (empty(azureReuseConfig.existingVnetName) ? _azureReuseConfigDefaults.existingVnetName : azureReuseConfig.existingVnetName)
orchestratorFunctionAppReuse: (empty(azureReuseConfig.orchestratorFunctionAppReuse) ? _azureReuseConfigDefaults.orchestratorFunctionAppReuse: toLower(azureReuseConfig.orchestratorFunctionAppReuse) == 'true')
existingOrchestratorFunctionAppResourceGroupName: (empty(azureReuseConfig.existingOrchestratorFunctionAppResourceGroupName) ? _azureReuseConfigDefaults.existingOrchestratorFunctionAppResourceGroupName : azureReuseConfig.existingOrchestratorFunctionAppResourceGroupName)
existingOrchestratorFunctionAppName: (empty(azureReuseConfig.existingOrchestratorFunctionAppName) ? _azureReuseConfigDefaults.existingOrchestratorFunctionAppName : azureReuseConfig.existingOrchestratorFunctionAppName)
dataIngestionFunctionAppReuse: (empty(azureReuseConfig.dataIngestionFunctionAppReuse) ? _azureReuseConfigDefaults.dataIngestionFunctionAppReuse : toLower(azureReuseConfig.dataIngestionFunctionAppReuse) == 'true')
existingDataIngestionFunctionAppResourceGroupName: (empty(azureReuseConfig.existingDataIngestionFunctionAppResourceGroupName) ? _azureReuseConfigDefaults.existingDataIngestionFunctionAppResourceGroupName : azureReuseConfig.existingDataIngestionFunctionAppResourceGroupName)
existingDataIngestionFunctionAppName: (empty(azureReuseConfig.existingDataIngestionFunctionAppName) ? _azureReuseConfigDefaults.existingDataIngestionFunctionAppName : azureReuseConfig.existingDataIngestionFunctionAppName)
appServiceReuse: (empty(azureReuseConfig.appServiceReuse) ? _azureReuseConfigDefaults.appServiceReuse : toLower(azureReuseConfig.appServiceReuse) == 'true')
existingAppServiceName: (empty(azureReuseConfig.existingAppServiceName) ? _azureReuseConfigDefaults.existingAppServiceName : azureReuseConfig.existingAppServiceName)
existingAppServiceNameResourceGroupName: (empty(azureReuseConfig.existingAppServiceNameResourceGroupName) ? _azureReuseConfigDefaults.existingAppServiceNameResourceGroupName : azureReuseConfig.existingAppServiceNameResourceGroupName)
orchestratorFunctionAppStorageReuse: (empty(azureReuseConfig.orchestratorFunctionAppStorageReuse) ? _azureReuseConfigDefaults.orchestratorFunctionAppStorageReuse : toLower(azureReuseConfig.orchestratorFunctionAppStorageReuse) == 'true')
existingOrchestratorFunctionAppStorageName: (empty(azureReuseConfig.existingOrchestratorFunctionAppStorageName) ? _azureReuseConfigDefaults.existingOrchestratorFunctionAppStorageName : azureReuseConfig.existingOrchestratorFunctionAppStorageName)
existingOrchestratorFunctionAppStorageResourceGroupName: (empty(azureReuseConfig.existingOrchestratorFunctionAppStorageResourceGroupName) ? _azureReuseConfigDefaults.existingOrchestratorFunctionAppStorageResourceGroupName : azureReuseConfig.existingOrchestratorFunctionAppStorageResourceGroupName)
dataIngestionFunctionAppStorageReuse: (empty(azureReuseConfig.dataIngestionFunctionAppStorageReuse) ? _azureReuseConfigDefaults.dataIngestionFunctionAppStorageReuse : toLower(azureReuseConfig.dataIngestionFunctionAppStorageReuse) == 'true')
existingDataIngestionFunctionAppStorageName: (empty(azureReuseConfig.existingDataIngestionFunctionAppStorageName) ? _azureReuseConfigDefaults.existingDataIngestionFunctionAppStorageName : azureReuseConfig.existingDataIngestionFunctionAppStorageName)
existingDataIngestionFunctionAppStorageResourceGroupName: (empty(azureReuseConfig.existingDataIngestionFunctionAppStorageResourceGroupName) ? _azureReuseConfigDefaults.existingDataIngestionFunctionAppStorageResourceGroupName : azureReuseConfig.existingDataIngestionFunctionAppStorageResourceGroupName)
}
)
// Security settings
// Note on Password Generation and KeyVault Usage:
// The 'azd' tool can automatically generate a password and store it in KeyVault. Refer to the mapping in 'main.parameters.json' for 'vmUserInitialPassword'.
// If the referenced KeyVault already exists, 'azd' will retrieve the password from it. If not, 'azd' will generate a random password and store it in the newly created KeyVault.
// This template ensures the creation of the KeyVault and sets the output to align with the usage in 'main.parameters.json'.
@minLength(6)
@maxLength(72)
@description('Test vm gpt user password. Use strong password with letters and numbers. Needed only when choosing network isolation and create bastion option. If not creating with network isolation you can write anything. Password must be between 6-72 characters long and must satisfy at least 3 of password complexity requirements from the following: 1-Contains an uppercase character, 2-Contains a lowercase character, 3-Contains a numeric digit, 4-Contains a special character, 5- Control characters are not allowed.')
@secure()
param vmUserInitialPassword string
@description('Deploy VM? If yes it will create the virtual machine to access the network isolated environment in the zero trust configuration.')
@allowed([true, false])
param deployVM bool = true
var _deployVM = deployVM
// var _vmUserInitialPassword = vmUserInitialPassword
@description('Test vm gpt user name. Needed only when choosing network isolation and create bastion option. If not you can leave it blank.')
param vmUserName string = ''
var _vmUserName = !empty(vmUserName) ? vmUserName : 'gptrag'
// PricipalId that will have access to KeyVault secrets, this is automatically set by the 'azd' tool to the principal runing azd
@description('Id of the user or app to assign application roles')
param principalId string = ''
// Network settings
@description('Network isolation? If yes it will create the private endpoints.')
@allowed([true, false])
param networkIsolation bool = false
var _networkIsolation = networkIsolation
// VNet settings
@description('Virtual network name, you can leave as it is to generate a random name.')
param vnetName string = ''
var _vnetName = _azureReuseConfig.vnetReuse ? _azureReuseConfig.existingVnetName : !empty(vnetName) ? vnetName : 'aivnet0-${resourceToken}'
@description('Address space for the virtual network')
param vnetAddress string = ''
var _vnetAddress = !empty(vnetAddress) ? vnetAddress : '10.0.0.0/23'
@description('Name of the AI services subnet')
param aiSubnetName string = ''
var _aiSubnetName = !empty(aiSubnetName) ? aiSubnetName : 'ai-subnet'
@description('Address prefix for the AI services subnet')
param aiSubnetPrefix string = ''
var _aiSubnetPrefix = !empty(aiSubnetPrefix) ? aiSubnetPrefix : '10.0.0.0/26'
@description('Name of the Bastion subnet')
param bastionSubnetName string = ''
var _bastionSubnetName = !empty(bastionSubnetName) ? bastionSubnetName : 'AzureBastionSubnet'
@description('Address prefix for the Bastion subnet')
param bastionSubnetPrefix string = ''
var _bastionSubnetPrefix = !empty(bastionSubnetPrefix) ? bastionSubnetPrefix : '10.0.0.64/26'
@description('Name of the App Integration subnet')
param appIntSubnetName string = ''
var _appIntSubnetName = !empty(appIntSubnetName) ? appIntSubnetName : 'app-int-subnet'
@description('Address prefix for the App Integration subnet')
param appIntSubnetPrefix string = ''
var _appIntSubnetPrefix = !empty(appIntSubnetPrefix) ? appIntSubnetPrefix : '10.0.0.128/26'
@description('Name of the App Services subnet')
param appServicesSubnetName string = ''
var _appServicesSubnetName = !empty(appServicesSubnetName) ? appServicesSubnetName : 'app-services-subnet'
@description('Address prefix for the App Services subnet')
param appServicesSubnetPrefix string = ''
var _appServicesSubnetPrefix = !empty(appServicesSubnetPrefix) ? appServicesSubnetPrefix : '10.0.0.192/26'
@description('Name of the Database subnet')
param databaseSubnetName string = ''
var _databaseSubnetName = !empty(databaseSubnetName) ? databaseSubnetName : 'database-subnet'
@description('Address prefix for the Database subnet')
param databaseSubnetPrefix string = ''
var _databaseSubnetPrefix = !empty(databaseSubnetPrefix) ? databaseSubnetPrefix : '10.0.1.0/26'
// flag that indicates if we're reusing a vnet
var _vnetReuse = _azureReuseConfig.vnetReuse
// Database settings
var _azureDbConfigDefaults = {
dbAccountName: 'dbgpt0-${resourceToken}'
dbDatabaseName: 'db0-${resourceToken}'
conversationContainerName: 'conversations'
modelsContainerName: 'models'
}
param azureDbConfig object = {}
var _azureDbConfig = union(_azureDbConfigDefaults, {
dbAccountName: (empty(azureDbConfig.dbAccountName) ? _azureDbConfigDefaults.dbAccountName : azureDbConfig.dbAccountName)
dbDatabaseName: (empty(azureDbConfig.dbDatabaseName) ? _azureDbConfigDefaults.dbDatabaseName : azureDbConfig.dbDatabaseName)
conversationContainerName: (empty(azureDbConfig.conversationContainerName) ? _azureDbConfigDefaults.conversationContainerName : azureDbConfig.conversationContainerName)
modelsContainerName: (empty(azureDbConfig.modelsContainerName) ? _azureDbConfigDefaults.modelsContainerName : azureDbConfig.modelsContainerName)
})
var _cosmosDbResourceGroupName = _azureReuseConfig.cosmosDbReuse ? _azureReuseConfig.existingCosmosDbResourceGroupName : _resourceGroupName
// Orchestrator settings
@description('Language used when orchestrator needs send error messages to the UX.')
param orchestratorMessagesLanguage string = ''
var _orchestratorMessagesLanguage = !empty(orchestratorMessagesLanguage) ? orchestratorMessagesLanguage : 'en'
//Frontend settings
@description('Language used for speech recognition in the frontend.')
// @allowed(['pt-BR', 'af-ZA', 'am-ET', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IL', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-OM', 'ar-PS', 'ar-QA', 'ar-SA', 'ar-SY', 'ar-TN', 'ar-YE', 'az-AZ', 'bg-BG', 'bn-IN', 'bs-BA', 'ca-ES', 'cs-CZ', 'cy-GB', 'da-DK', 'de-AT', 'de-CH', 'de-DE', 'el-GR', 'en-AU', 'en-CA', 'en-GB', 'en-GH', 'en-HK', 'en-IE', 'en-IN', 'en-KE', 'en-NG', 'en-NZ', 'en-PH', 'en-SG', 'en-TZ', 'en-US', 'en-ZA', 'es-AR', 'es-BO', 'es-CL', 'es-CO', 'es-CR', 'es-CU', 'es-DO', 'es-EC', 'es-ES', 'es-GQ', 'es-GT', 'es-HN', 'es-MX', 'es-NI', 'es-PA', 'es-PE', 'es-PR', 'es-PY', 'es-SV', 'es-US', 'es-UY', 'es-VE', 'et-EE', 'eu-ES', 'fa-IR', 'fi-FI', 'fil-PH', 'fr-BE', 'fr-CA', 'fr-CH', 'fr-FR', 'ga-IE', 'gl-ES', 'gu-IN', 'he-IL', 'hi-IN', 'hr-HR', 'hu-HU', 'hy-AM', 'id-ID', 'is-IS', 'it-CH', 'it-IT', 'ja-JP', 'jv-ID', 'ka-GE', 'kk-KZ', 'km-KH', 'kn-IN', 'ko-KR', 'lo-LA', 'lt-LT', 'lv-LV', 'mk-MK', 'ml-IN', 'mn-MN', 'mr-IN', 'ms-MY', 'mt-MT', 'my-MM', 'nb-NO', 'ne-NP', 'nl-BE', 'nl-NL', 'pl-PL', 'ps-AF', 'pt-PT', 'ro-RO', 'ru-RU', 'si-LK', 'sk-SK', 'sl-SI', 'so-SO', 'sq-AL', 'sr-RS', 'sv-SE', 'sw-KE', 'sw-TZ', 'ta-IN', 'te-IN', 'th-TH', 'tr-TR', 'uk-UA', 'uz-UZ', 'vi-VN', 'wuu-CN', 'yue-CN', 'zh-CN', 'zh-CN-shandong', 'zh-CN-sichuan', 'zh-HK', 'zh-TW', 'zu-ZA' ])
param speechRecognitionLanguage string = ''
var _speechRecognitionLanguage = !empty(speechRecognitionLanguage) ? speechRecognitionLanguage : 'en-US'
@description('Language used for speech synthesis in the frontend.')
// @allowed(['pt-BR', 'es-ES', 'es-MX','ar-EG', 'ar-SA', 'ca-ES', 'cs-CZ', 'da-DK', 'de-AT', 'de-CH', 'de-DE', 'en-AU', 'en-CA', 'en-GB', 'en-HK', 'en-IE', 'en-IN', 'en-US', 'es-ES', 'es-MX', 'fi-FI', 'fr-BE', 'fr-CA', 'fr-CH', 'fr-FR', 'hi-IN', 'hu-HU', 'id-ID', 'it-IT', 'ja-JP', 'ko-KR', 'nb-NO', 'nl-BE', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'sv-SE', 'th-TH', 'tr-TR', 'zh-CN', 'zh-HK', 'zh-TW'])
param speechSynthesisLanguage string = ''
var _speechSynthesisLanguage = !empty(speechSynthesisLanguage) ? speechSynthesisLanguage : 'en-US'
@description('Voice used for speech synthesis in the frontend.')
// @allowed([ 'pt-BR-FranciscaNeural', 'es-MX-BeatrizNeural', 'en-US-RyanMultilingualNeural', 'de-DE-AmalaNeural', 'fr-FR-DeniseNeural'])
param speechSynthesisVoiceName string = ''
var _speechSynthesisVoiceName = !empty(speechSynthesisVoiceName) ? speechSynthesisVoiceName : 'en-US-RyanMultilingualNeural'
// Function app settings
@description('Python runtime version in function apps')
// @allowed(['3.10', '3.11'])
param funcAppRuntimeVersion string = ''
var _funcAppRuntimeVersion = !empty(funcAppRuntimeVersion) ? funcAppRuntimeVersion : '3.11'
@description('Python runtime version in app service')
// @allowed(['3.10', '3.11', '3.12'])
param appServiceRuntimeVersion string = ''
var _appServiceRuntimeVersion = !empty(appServiceRuntimeVersion) ? appServiceRuntimeVersion : '3.12'
// Azure OpenAI settings
@description('GPT model used to answer user questions. Don\'t forget to check region availability.')
// @allowed([ 'gpt-35-turbo','gpt-35-turbo-16k', 'gpt-4', 'gpt-4-32k', 'gpt-4o', 'gpt-4o-mini' ])
param chatGptModelName string = ''
var _chatGptModelName = !empty(chatGptModelName) ? chatGptModelName : 'gpt-4o'
@description('GPT model deployment type.')
// @allowed([ 'Standard', 'ProvisionedManaged', 'GlobalStandard'])
param chatGptModelDeploymentType string = ''
var _chatGptModelDeploymentType = !empty(chatGptModelDeploymentType) ? chatGptModelDeploymentType : 'GlobalStandard'
@description('GPT model version.')
// @allowed([ '0613', '1106', '1106-Preview', '0125-preview', 'turbo-2024-04-09', '2024-05-13', '2024-11-20'])
param chatGptModelVersion string = ''
var _chatGptModelVersion = !empty(chatGptModelVersion) ? chatGptModelVersion : '2024-11-20'
@description('GPT model deployment name.')
param chatGptDeploymentName string = ''
var _chatGptDeploymentName = !empty(chatGptDeploymentName) ? chatGptDeploymentName : 'chat'
@description('GPT model tokens per Minute Rate Limit (thousands).')
// @minValue(1)
// @maxValue(300)
param chatGptDeploymentCapacity int = 0
var _chatGptDeploymentCapacity = chatGptDeploymentCapacity != 0 ? chatGptDeploymentCapacity : 40
@description('Embeddings model used to generate vector embeddings. Don\'t forget to check region availability.')
// @allowed([ 'text-embedding-ada-002', 'text-embedding-3-small', 'text-embedding-3-large' ])
param embeddingsModelName string = ''
var _embeddingsModelName = !empty(embeddingsModelName) ? embeddingsModelName : 'text-embedding-3-large'
@description('Embeddings model deployment type.')
// @allowed([ 'Standard'])
param embeddingsDeploymentType string = 'Standard'
var _embeddingsDeploymentType = !empty(embeddingsDeploymentType) ? embeddingsDeploymentType : 'Standard'
@description('Embeddings model version.')
// @allowed([ '1', '2' ])
param embeddingsModelVersion string = ''
var _embeddingsModelVersion = !empty(embeddingsModelVersion) ? embeddingsModelVersion : '1'
@description('Embeddings model deployment name.')
param embeddingsDeploymentName string = ''
var _embeddingsDeploymentName = !empty(embeddingsDeploymentName) ? embeddingsDeploymentName : 'text-embedding'
@description('Vector embeddings size.')
// @allowed([ 1536, 3072 ])
param embeddingsVectorSize int = 0
var _embeddingsVectorSize = embeddingsVectorSize != 0 ? embeddingsVectorSize : 3072
@description('Embeddings model tokens per Minute Rate Limit (thousands).')
param embeddingsDeploymentCapacity int = 0
var _embeddingsDeploymentCapacity = embeddingsDeploymentCapacity != 0 ? embeddingsDeploymentCapacity : 40
@description('Azure OpenAI API version.')
param openaiApiVersion string = ''
var _openaiApiVersion = !empty(openaiApiVersion) ? openaiApiVersion : '2024-10-21'
@description('Enables LLM monitoring to generate conversation metrics.')
@allowed([true, false])
param chatGptLlmMonitoring bool = false
var _chatGptLlmMonitoring = chatGptLlmMonitoring != null ? chatGptLlmMonitoring : true
// Document intelligence settings
var _docintApiVersion = '2024-11-30'
// AI search settings
@description('Orchestrator supports the following retrieval approaches: term, vector, hybrid(term + vector search), or use oyd feature of Azure OpenAI.')
// @allowed(['term', 'vector', 'hybrid', 'oyd' ])
param retrievalApproach string = ''
var _retrievalApproach = !empty(retrievalApproach) ? retrievalApproach : 'hybrid'
@description('Analyzer language used by Azure search to analyze indexes text content.')
// @allowed(['standard', 'pt-Br.microsoft', 'es.microsoft', 'ar.microsoft', 'bn.microsoft', 'bg.microsoft', 'ca.microsoft', 'zh-Hans.microsoft', 'zh-Hant.microsoft', 'hr.microsoft', 'cs.microsoft', 'da.microsoft', 'nl.microsoft', 'en.microsoft', 'et.microsoft', 'fi.microsoft', 'fr.microsoft', 'de.microsoft', 'el.microsoft', 'gu.microsoft', 'he.microsoft', 'hi.microsoft', 'hu.microsoft', 'is.microsoft', 'id.microsoft', 'it.microsoft', 'ja.microsoft', 'kn.microsoft', 'ko.microsoft', 'lv.microsoft', 'lt.microsoft', 'ml.microsoft', 'ms.microsoft', 'mr.microsoft', 'nb.microsoft', 'pl.microsoft', 'pt-Pt.microsoft', 'pa.microsoft', 'ro.microsoft', 'ru.microsoft', 'sr-cyrillic.microsoft', 'sr-latin.microsoft', 'sk.microsoft', 'sl.microsoft', 'sv.microsoft', 'ta.microsoft', 'te.microsoft', 'th.microsoft', 'tr.microsoft', 'uk.microsoft', 'ur.microsoft', 'vi.microsoft' ])
param searchAnalyzerName string = ''
var _searchAnalyzerName = !empty(searchAnalyzerName) ? searchAnalyzerName : 'standard'
@description('Use semantic reranking on top of search results?.')
@allowed([true, false])
param useSemanticReranking bool = true
var _useSemanticReranking = useSemanticReranking != null ? useSemanticReranking : true
var _searchServiceSkuName = _networkIsolation?'standard2':'standard'
@description('Search index name.')
param searchIndex string = ''
var _searchIndex = !empty(searchIndex) ? searchIndex : 'ragindex'
// @allowed([ '2024-07-01', '2023-11-01', '2023-10-01-Preview', '2024-05-01-preview' ])
// Requires version 2023-10-01-Preview or higher for indexProjections and MIS authResourceId.
param searchApiVersion string = ''
var _searchApiVersion = !empty(searchApiVersion) ? searchApiVersion : '2024-07-01'
@description('Frequency of search reindexing. PT5M (5 min), PT1H (1 hour), P1D (1 day).')
// @allowed(['PT5M', 'PT1H', 'P1D'])
param searchIndexInterval string = ''
var _searchIndexInterval = !empty(searchIndexInterval) ? searchIndexInterval : 'PT1H'
@description('Use Search Service Managed Identity to Connect to data ingestion function?')
// @allowed([true, false])
param searchUseMIS bool = false
var _azureSearchUseMIS = searchUseMIS != null ? searchUseMIS : false
// chunking settings
@description('The number of tokens in each chunk.')
param chunkNumTokens string = ''
var _chunkNumTokens = !empty(chunkNumTokens) ? chunkNumTokens : '2048'
@description('The minimum chunk size below which chunks will be filtered.')
param chunkMinSize string = ''
var _chunkMinSize = !empty(chunkMinSize) ? chunkMinSize : '100'
@description('The number of tokens to overlap between chunks.')
param chunkTokenOverlap string = ''
var _chunkTokenOverlap = !empty(chunkTokenOverlap) ? chunkTokenOverlap : '200'
// Storage settings
@description('Name of the container where source documents will be stored.')
param storageContainerName string = ''
var _storageContainerName = !empty(storageContainerName) ? storageContainerName : 'documents'
var _storageImagesContainerName = '${_storageContainerName}-images'
var _storageNl2sqlContainerName = 'nl2sql'
@description('Storage Account Name. Use your own name convention or leave as it is to generate a random name.')
param storageAccountName string = ''
var _storageAccountName = _azureReuseConfig.storageReuse ? _azureReuseConfig.existingStorageName : !empty(storageAccountName) ? storageAccountName : 'strag0${resourceToken}'
var _storageAccountResourceGroupName = _azureReuseConfig.storageReuse ? _azureReuseConfig.existingStorageResourceGroupName : _resourceGroupName
// Resource name settings
// The name for each service can be set from environment variables which are mapped in main.parameters.json.
// If no maping to specific name is defined, a unique name is generated for each service based on the resourceToken created above.
@description('Key Vault Name. Use your own name convention or leave as it is to generate a random name.')
param keyVaultName string = ''
var _keyVaultName = _azureReuseConfig.keyVaultReuse ? _azureReuseConfig.existingKeyVaultName : !empty(keyVaultName) ? keyVaultName : 'kv0-${resourceToken}'
var _keyVaultResourceGroupName = _azureReuseConfig.keyVaultReuse ? _azureReuseConfig.existingKeyVaultResourceGroupName : _resourceGroupName
@description('OpenAI Service Name. Use your own name convention or leave as it is to generate a random name.')
param openAiServiceName string = ''
var _openAiServiceName = _azureReuseConfig.aoaiReuse ? _azureReuseConfig.existingAoaiName : !empty(openAiServiceName) ? openAiServiceName : 'oai0-${resourceToken}'
var _openAiResourceGroupName = _azureReuseConfig.aoaiReuse ? _azureReuseConfig.existingAoaiResourceGroupName : _resourceGroupName
@description('AI services multi-service name. Use your own name convention or leave as it is to generate a random name.')
param aiServicesName string = ''
var _aiServicesName = _azureReuseConfig.aiServicesReuse ? _azureReuseConfig.existingAiServicesName : !empty(aiServicesName) ? aiServicesName : 'ai0-${resourceToken}'
var _aiServicesResourceGroupName = _azureReuseConfig.aiServicesReuse ? _azureReuseConfig.existingAiServicesResourceGroupName : _resourceGroupName
@description('App Service Plan Name. Use your own name convention or leave as it is to generate a random name.')
param appServicePlanName string = ''
var _appServicePlanName = _azureReuseConfig.appServicePlanReuse ? _azureReuseConfig.existingAppServicePlanName : !empty(appServicePlanName) ? appServicePlanName : 'appplan0-${resourceToken}'
@description('App Insights Name. Use your own name convention or leave as it is to generate a random name.')
param appInsightsName string = ''
var _appInsightsName = _azureReuseConfig.appInsightsReuse ? _azureReuseConfig.existingAppInsightsName : !empty(appInsightsName) ? appInsightsName : 'appins0-${resourceToken}'
var _appInsightsResourceGroupName = _azureReuseConfig.appInsightsReuse ? _azureReuseConfig.existingAppInsightsResourceGroupName : _resourceGroupName
@description('Front-end App Service Name. Use your own name convention or leave as it is to generate a random name.')
param appServiceName string = ''
var _appServiceName = _azureReuseConfig.appServiceReuse ? _azureReuseConfig.existingAppServiceName : !empty(appServiceName) ? appServiceName : 'webgpt0-${resourceToken}'
@description('Load testing resource name. Use your own name convention or leave as it is to generate a random name.')
param loadTestingName string = ''
var _loadtestingName = !empty(loadTestingName) ? loadTestingName : 'loadtest0-${resourceToken}'
@description('Orchestrator Function Name. Use your own name convention or leave as it is to generate a random name.')
param orchestratorFunctionAppName string = ''
var _orchestratorFunctionAppName = _azureReuseConfig.orchestratorFunctionAppReuse ? _azureReuseConfig.existingOrchestratorFunctionAppName : !empty(orchestratorFunctionAppName) ? orchestratorFunctionAppName : 'fnorch0-${resourceToken}'
var _orchestratorFunctionAppResourceGroupName = _azureReuseConfig.orchestratorFunctionAppReuse ? _azureReuseConfig.existingOrchestratorFunctionAppResourceGroupName : _resourceGroupName
@description('Data Ingestion Function Name. Use your own name convention or leave as it is to generate a random name.')
param dataIngestionFunctionAppName string = ''
var _dataIngestionFunctionAppName = _azureReuseConfig.dataIngestionFunctionAppReuse ? _azureReuseConfig.existingDataIngestionFunctionAppName : !empty(dataIngestionFunctionAppName) ? dataIngestionFunctionAppName : 'fninges0-${resourceToken}'
var _dataIngestionFunctionAppResourceGroupName = _azureReuseConfig.dataIngestionFunctionAppReuse ? _azureReuseConfig.existingDataIngestionFunctionAppResourceGroupName : _resourceGroupName
@description('Search Service Name. Use your own name convention or leave as it is to generate a random name.')
param searchServiceName string = ''
var _searchServiceName = _azureReuseConfig.aiSearchReuse ? _azureReuseConfig.existingAiSearchName : !empty(searchServiceName) ? searchServiceName : 'search0-${resourceToken}'
var _searchResourceGroupName = _azureReuseConfig.aiSearchReuse ? _azureReuseConfig.existingAiSearchResourceGroupName : _resourceGroupName
@description('The name of the Azure Storage Account Private Endpoint. If left empty, a random name will be generated.')
param azureStorageAccountPe string = ''
var _azureStorageAccountPe = !empty(azureStorageAccountPe) ? azureStorageAccountPe : 'stragpe0-${resourceToken}'
@description('The name of the Azure Cosmos DB Private Endpoint. If left empty, a random name will be generated.')
param azureDbAccountPe string = ''
var _azureDbAccountPe = !empty(azureDbAccountPe) ? azureDbAccountPe : 'dbgptpe0-${resourceToken}'
@description('The name of the Azure Key Vault Private Endpoint. If left empty, a random name will be generated.')
param azureKeyvaultPe string = ''
var _azureKeyvaultPe = !empty(azureKeyvaultPe) ? azureKeyvaultPe : 'kvpe0-${resourceToken}'
@description('The name of the Azure Orchestrator Private Endpoint. If left empty, a random name will be generated.')
param azureOrchestratorPe string = ''
var _azureOrchestratorPe = !empty(azureOrchestratorPe) ? azureOrchestratorPe : 'orchestratorPe-${resourceToken}'
@description('The name of the Azure Frontend Private Endpoint. If left empty, a random name will be generated.')
param azureFrontendPe string = ''
var _azureFrontendPe = !empty(azureFrontendPe) ? azureFrontendPe : 'frontendPe-${resourceToken}'
@description('The name of the Azure Data Ingestion Private Endpoint. If left empty, a random name will be generated.')
param azureDataIngestionPe string = ''
var _azureDataIngestionPe = !empty(azureDataIngestionPe) ? azureDataIngestionPe : 'ingestionPe-${resourceToken}'
@description('The name of the Azure AI Services Private Endpoint. If left empty, a random name will be generated.')
param azureAiServicesPe string = ''
var _azureAiServicesPe = !empty(azureAiServicesPe) ? azureAiServicesPe : 'aiServicesPe-${resourceToken}'
@description('The name of the Azure OpenAI Private Endpoint. If left empty, a random name will be generated.')
param azureOpenAiPe string = ''
var _azureOpenAiPe = !empty(azureOpenAiPe) ? azureOpenAiPe : 'openAiPe-${resourceToken}'
@description('The name of the Azure Search Private Endpoint. If left empty, a random name will be generated.')
param azureSearchPe string = ''
var _azureSearchPe = !empty(azureSearchPe) ? azureSearchPe : 'searchPe-${resourceToken}'
@description('The name of the VM Key Vault Secret. If left empty, a random name will be generated.')
param vmKeyVaultSecName string = ''
var _vmKeyVaultSecName = !empty(vmKeyVaultSecName) ? vmKeyVaultSecName : 'vmUserInitialPassword'
@description('The name of the Zero Trust VM. If left empty, a random name will be generated.')
param ztVmName string = ''
var _ztVmName = !empty(ztVmName) ? ztVmName : 'testvm-${resourceToken}'
@description('The name of the Bastion Key Vault. If left empty, a random name will be generated.')
param bastionKvName string = ''
var _bastionKvName = !empty(bastionKvName) ? bastionKvName : 'bastionkv-${resourceToken}'
var _orchestratorEndpoint = 'https://${_orchestratorFunctionAppName}.azurewebsites.net/api/orc'
/////////////////////////////////////////////////////////////////////////////
// TEMPLATE MODULES
/////////////////////////////////////////////////////////////////////////////
// Networking
module vnet './core/network/vnet.bicep' = if (_networkIsolation && !_vnetReuse) {
name: 'virtual-network'
scope: resourceGroup
params: {
location: location
vnetName: _vnetName
vnetReuse: _vnetReuse
existingVnetResourceGroupName: _azureReuseConfig.existingVnetResourceGroupName
tags: tags
vnetAddress: _vnetAddress
appServicePlanId: appServicePlan.outputs.id
appServicePlanName: appServicePlan.outputs.name
aiSubnetName: _aiSubnetName
aiSubnetPrefix: _aiSubnetPrefix
appIntSubnetName: _appIntSubnetName
appIntSubnetPrefix: _appIntSubnetPrefix
appServicesSubnetName: _appServicesSubnetName
appServicesSubnetPrefix: _appServicesSubnetPrefix
databaseSubnetName: _databaseSubnetName
databaseSubnetPrefix: _databaseSubnetPrefix
bastionSubnetName: _bastionSubnetName
bastionSubnetPrefix: _bastionSubnetPrefix
}
}
module blobDnsZone './core/network/private-dns-zones.bicep' = if (_networkIsolation && !_vnetReuse) {
name: 'blob-dnzones'
scope: resourceGroup
params: {
dnsZoneName: 'privatelink.blob.core.windows.net'
tags: tags
virtualNetworkName: _networkIsolation?vnet.outputs.name:''
}
}
module documentsDnsZone './core/network/private-dns-zones.bicep' = if (_networkIsolation && !_vnetReuse) {
name: 'documents-dnzones'
scope: resourceGroup
params: {
dnsZoneName: 'privatelink.documents.azure.com'
tags: tags
virtualNetworkName: _networkIsolation?vnet.outputs.name:''
}
}
module vaultDnsZone './core/network/private-dns-zones.bicep' = if (_networkIsolation && !_vnetReuse) {
name: 'vault-dnzones'
scope: resourceGroup
params: {
dnsZoneName: 'privatelink.vaultcore.azure.net'
tags: tags
virtualNetworkName: _networkIsolation?vnet.outputs.name:''
}
}
module websitesDnsZone './core/network/private-dns-zones.bicep' = if (_networkIsolation && !_vnetReuse) {
name: 'websites-dnzones'
scope: resourceGroup
params: {
dnsZoneName: 'privatelink.azurewebsites.net'
tags: tags
virtualNetworkName: _networkIsolation?vnet.outputs.name:''
}
}
module aiservicesDnsZone './core/network/private-dns-zones.bicep' = if (_networkIsolation && !_vnetReuse) {
name: 'aiservices-dnzones'
scope: resourceGroup
params: {
dnsZoneName: 'privatelink.cognitiveservices.azure.com'
tags: tags
virtualNetworkName: _networkIsolation?vnet.outputs.name:''
}
}
module openaiDnsZone './core/network/private-dns-zones.bicep' = if (_networkIsolation && !_vnetReuse) {
name: 'openai-dnzones'
scope: resourceGroup
params: {
dnsZoneName: 'privatelink.openai.azure.com'
tags: tags
virtualNetworkName: _networkIsolation?vnet.outputs.name:''
}
}
module searchDnsZone './core/network/private-dns-zones.bicep' = if (_networkIsolation && !_vnetReuse) {
name: 'searchs-dnzones'
scope: resourceGroup
params: {
dnsZoneName: 'privatelink.search.windows.net'
tags: tags
virtualNetworkName: _networkIsolation?vnet.outputs.name:''
}
}
module testvm './core/vm/dsvm.bicep' = if (_networkIsolation && !_vnetReuse && _deployVM) {
name: 'testvm'
scope: resourceGroup
params: {
location: location
name: _ztVmName
tags: tags
subnetId: _networkIsolation?vnet.outputs.aiSubId:''
bastionSubId: _networkIsolation?vnet.outputs.bastionSubId:''
vmUserPassword: vmUserInitialPassword
vmUserName: _vmUserName
keyVaultName: _bastionKvName
// this is the named of the secret to store the vm password in keyvault. It matches what is used on main.parameters.json
vmUserPasswordKey: _vmKeyVaultSecName
principalId: principalId
}
}
module testvmSearchAccess './core/security/search-service-contributor.bicep' = if (_networkIsolation && !_vnetReuse && _deployVM) {
name: 'dsvm-search-access'
scope: az.resourceGroup(_searchResourceGroupName)
params: {
principalId: testvm.outputs.vmPrincipalId
resourceName: searchService.outputs.name
}
}
module principalSearchAccess './core/security/search-service-contributor.bicep' = {
name: 'principal-search-access'
scope: az.resourceGroup(_searchResourceGroupName)
params: {
principalId: principalId
resourceName: searchService.outputs.name
}
}
// Storage
module storage './core/storage/storage-account.bicep' = {
name: 'storage'
scope: resourceGroup
params: {
name: _storageAccountName
location: location
storageReuse: _azureReuseConfig.storageReuse
existingStorageResourceGroupName: _azureReuseConfig.existingStorageResourceGroupName
tags: tags
publicNetworkAccess: _networkIsolation?'Disabled':'Enabled'
allowBlobPublicAccess: false // Disable anonymous access
containers: [
{ name: _storageContainerName, publicAccess: 'None' }
{ name: _storageImagesContainerName, publicAccess: 'None' }
{ name: _storageNl2sqlContainerName, publicAccess: 'None' }
]
deleteRetentionPolicy: {
enabled: true
days: 7
}
}
}
module storagepe './core/network/private-endpoint.bicep' = if (_networkIsolation && !_vnetReuse) {
name: 'storagepe'
scope: resourceGroup
params: {
location: location
name: _azureStorageAccountPe
tags: tags
subnetId: _networkIsolation?vnet.outputs.aiSubId:''
serviceId: storage.outputs.id
groupIds: ['blob']
dnsZoneId: _networkIsolation?blobDnsZone.outputs.id:''
}
}
// Database
module cosmosAccount './core/db/cosmos.bicep' = {
name: 'cosmosaccount'
scope: resourceGroup
params: {
accountName: _azureDbConfig.dbAccountName
cosmosDbReuse: _azureReuseConfig.cosmosDbReuse
existingCosmosDbResourceGroupName: _azureReuseConfig.existingCosmosDbResourceGroupName
existingCosmosDbAccountName: _azureReuseConfig.existingCosmosDbAccountName
publicNetworkAccess: _networkIsolation?'Disabled':'Enabled'
location: location
conversationContainerName: _azureDbConfig.conversationContainerName
modelsContainerName: _azureDbConfig.modelsContainerName
databaseName: _azureDbConfig.dbDatabaseName
tags: tags
secretName: 'azureDBkey'
keyVaultName: keyVault.outputs.name
}
}
module cosmospe './core/network/private-endpoint.bicep' = if (_networkIsolation && !_vnetReuse) {
name: 'cosmospe'
scope: resourceGroup
params: {
location: location
name: _azureDbAccountPe
tags: tags
subnetId: _networkIsolation?vnet.outputs.databaseSubId:''
serviceId: cosmosAccount.outputs.id
groupIds: ['Sql']
dnsZoneId: _networkIsolation?documentsDnsZone.outputs.id:''
}
}
// Security
module keyVault './core/security/keyvault.bicep' = {
name: 'keyvault'
scope: resourceGroup
params: {
name: _keyVaultName
location: location
keyVaultReuse : _azureReuseConfig.keyVaultReuse
existingKeyVaultResourceGroupName : _azureReuseConfig.existingKeyVaultResourceGroupName
publicNetworkAccess: _networkIsolation?'Disabled':'Enabled'
tags: tags
principalId: principalId
// this is the named of the secret to store the vm password in keyvault. It matches what is used on main.parameters.json
// vmUserPasswordKey: _vmKeyVaultSecName
// vmUserPassword: _vmUserInitialPassword
}
}
module keyvaultpe './core/network/private-endpoint.bicep' = if (_networkIsolation && !_vnetReuse) {
name: 'keyvaultpe'
scope: resourceGroup
params: {
location: location
name: _azureKeyvaultPe
tags: tags
subnetId: _networkIsolation?vnet.outputs.aiSubId:''
serviceId: keyVault.outputs.id
groupIds: ['Vault']
dnsZoneId: _networkIsolation?vaultDnsZone.outputs.id:''
}
}
// App Service Plan
module appServicePlan './core/host/appserviceplan.bicep' = {
name: 'appserviceplan'
scope: resourceGroup
params: {
name: _appServicePlanName
location: location
appServicePlanReuse : _azureReuseConfig.appServicePlanReuse
existingAppServicePlanResourceGroupName : _azureReuseConfig.existingAppServicePlanResourceGroupName
tags: tags
sku: {
name: 'P0v3'
capacity: 1
}
kind: 'linux'
}
}
// App Insights
module appInsights './core/host/appinsights.bicep' = {
name: 'appinsights'
scope: resourceGroup
params: {
applicationInsightsName: _appInsightsName
appInsightsLocation: location
appInsightsReuse: _azureReuseConfig.appInsightsReuse
existingAppInsightsResourceGroupName: _azureReuseConfig.existingAppInsightsResourceGroupName
}
}
// Orchestrator Function App
module orchestrator './core/host/functions.bicep' = {
name: 'orchestrator'
scope: resourceGroup
params: {
name: _orchestratorFunctionAppName
functionAppResourceGroupName: _orchestratorFunctionAppResourceGroupName
functionAppReuse: _azureReuseConfig.orchestratorFunctionAppReuse
location: location
networkIsolation: (_networkIsolation && !_vnetReuse)?true:false
vnetName: (_networkIsolation && !_vnetReuse)?vnet.outputs.name:''
subnetId: (_networkIsolation && !_vnetReuse)?vnet.outputs.appIntSubId:''
tags: union(tags, { 'azd-service-name': 'orchestrator' })
identityType: 'SystemAssigned'
keyVaultName: keyVault.outputs.name
keyVaultResourceGroupName: _keyVaultResourceGroupName
applicationInsightsName: appInsights.outputs.name
applicationInsightsResourceGroupName: _appInsightsResourceGroupName
appServicePlanId: appServicePlan.outputs.id
runtimeName: 'python'
runtimeVersion: _funcAppRuntimeVersion
storageAccountName: orchestratorStorage.outputs.name
storageResourceGroupName: _orchestratorFunctionAppResourceGroupName // creates storage account in the same resource group as the function app
numberOfWorkers: 2
functionAppScaleLimit: 2
minimumElasticInstanceCount: 1
allowedOrigins: [ '*' ]
appSettings: [
{
name: 'AZURE_DB_ID'
value: _azureDbConfig.dbAccountName
}
{
name: 'AZURE_DB_NAME'
value: _azureDbConfig.dbDatabaseName
}
{
name: 'AZURE_DB_CONVERSATIONS_CONTAINER_NAME'
value: _azureDbConfig.conversationContainerName
}
{
name: 'AZURE_DB_MODELS_CONTAINER_NAME'
value: _azureDbConfig.modelsContainerName
}
{
name: 'AZURE_KEY_VAULT_NAME'
value: keyVault.outputs.name
}
{
name: 'AZURE_SEARCH_SERVICE'
value: _searchServiceName
}
{
name: 'AZURE_SEARCH_INDEX'
value: _searchIndex
}
{
name: 'AZURE_SEARCH_APPROACH'
value: _retrievalApproach
}
{
name: 'AZURE_SEARCH_USE_SEMANTIC'
value: _useSemanticReranking
}
{
name: 'AZURE_SEARCH_API_VERSION'
value: _searchApiVersion
}
{
name: 'AZURE_OPENAI_RESOURCE'
value: _openAiServiceName
}
{
name: 'AZURE_OPENAI_CHATGPT_MODEL'
value: _chatGptModelName
}
{
name: 'AZURE_OPENAI_CHATGPT_DEPLOYMENT'
value: _chatGptDeploymentName
}
{
name: 'AZURE_OPENAI_CHATGPT_LLM_MONITORING'
value: _chatGptLlmMonitoring
}
{
name: 'AZURE_OPENAI_API_VERSION'
value: _openaiApiVersion
}
{
name: 'AZURE_OPENAI_LOAD_BALANCING'
value: 'false'
}
{
name: 'AZURE_OPENAI_EMBEDDING_MODEL'
value: _embeddingsModelName
}
{
name: 'AZURE_OPENAI_EMBEDDING_DEPLOYMENT'
value: _embeddingsDeploymentName
}
{
name: 'AZURE_EMBEDDINGS_VECTOR_SIZE'
value: _embeddingsVectorSize
}
{
name: 'AZURE_OPENAI_STREAM'
value: 'false'
}
{
name: 'ORCHESTRATOR_MESSAGES_LANGUAGE'
value: _orchestratorMessagesLanguage
}
{
name: 'ENABLE_ORYX_BUILD'
value: 'true'
}
{
name: 'BING_SEARCH_TOP_K'
value: '3'
}
{
name: 'BING_RETRIEVAL'
value: 'false'
}
{
name: 'BING_SEARCH_MAX_TOKENS'
value: '1000'
}
{
name: 'SQL_RETRIEVAL'
value: 'false'
}
{
name: 'SQL_TOP_K'
value: '3'
}
{
name: 'SQL_MAX_TOKENS'
value: '1000'
}
{
name: 'TERADATA_TOP_K'
value: '3'
}
{
name: 'TERADATA_RETRIEVAL'
value: 'false'
}
{
name: 'TERADATA_MAX_TOKENS'
value: '1000'
}
{
name: 'RETRIEVAL_PRIORITY'
value: 'search'
}
{
name: 'SCM_DO_BUILD_DURING_DEPLOYMENT'
value: 'true'
}
{
name: 'LOGLEVEL'
value: 'INFO'
}
]
}
dependsOn: [
appServicePlan
]
}
// Orchestrator Storage Account
module orchestratorStorage './core/storage/function-storage-account.bicep' = {
name: 'orchestratorstorage'
scope: resourceGroup
params: {
name: '${_storageAccountName}orc'
location: location
tags: tags
containers: [{name: 'deploymentpackage'}]
publicNetworkAccess: _networkIsolation?'Disabled':'Enabled'
}
}
module orchestratorStoragepe './core/network/private-endpoint.bicep' = if (_networkIsolation && !_vnetReuse) {
name: 'orchestratorstoragepe'
scope: resourceGroup
params: {
location: location
name: '${_azureStorageAccountPe}orc'
tags: tags
subnetId: _networkIsolation?vnet.outputs.appServicesSubId:''
serviceId: orchestratorStorage.outputs.id
groupIds: ['blob']
dnsZoneId: _networkIsolation?blobDnsZone.outputs.id:''
}
}
module orchestratorPe './core/network/private-endpoint.bicep' = if (_networkIsolation && !_vnetReuse) {
name: 'orchestratorPe'
scope: resourceGroup
params: {