@@ -31,7 +31,6 @@ var actualSearchServiceSemanticRankerLevel = (searchServiceSkuName == 'free') ?
31
31
param useSearchServiceKey bool = searchServiceSkuName == 'free'
32
32
33
33
param storageAccountName string = ''
34
- param keyVaultResourceGroupName string = ''
35
34
param storageResourceGroupName string = ''
36
35
param storageResourceGroupLocation string = location
37
36
param storageContainerName string = 'content'
@@ -47,12 +46,12 @@ param openAiServiceName string = ''
47
46
param openAiResourceGroupName string = ''
48
47
param useGPT4V bool = false
49
48
49
+ param keyVaultResourceGroupName string = ''
50
50
param keyVaultServiceName string = ''
51
- param computerVisionSecretName string = 'computerVisionSecret'
52
51
param searchServiceSecretName string = 'searchServiceSecret'
53
52
54
53
@description ('Location for the OpenAI resource group' )
55
- @allowed (['canadaeast' , 'eastus' , 'eastus2' , 'francecentral' , 'switzerlandnorth' , 'uksouth' , 'japaneast' , 'northcentralus' , 'australiaeast' , 'swedencentral' ])
54
+ @allowed ([ 'canadaeast' , 'eastus' , 'eastus2' , 'francecentral' , 'switzerlandnorth' , 'uksouth' , 'japaneast' , 'northcentralus' , 'australiaeast' , 'swedencentral' ])
56
55
@metadata ({
57
56
azd : {
58
57
type : 'location'
@@ -70,7 +69,7 @@ param documentIntelligenceResourceGroupName string = ''
70
69
// Limited regions for new version:
71
70
// https://learn.microsoft.com/azure/ai-services/document-intelligence/concept-layout
72
71
@description ('Location for the Document Intelligence resource group' )
73
- @allowed (['eastus' , 'westus2' , 'westeurope' ])
72
+ @allowed ([ 'eastus' , 'westus2' , 'westeurope' ])
74
73
@metadata ({
75
74
azd : {
76
75
type : 'location'
@@ -129,7 +128,7 @@ var resourceToken = toLower(uniqueString(subscription().id, environmentName, loc
129
128
var tags = { 'azd-env-name' : environmentName }
130
129
var computerVisionName = !empty (computerVisionServiceName ) ? computerVisionServiceName : '${abbrs .cognitiveServicesComputerVision }${resourceToken }'
131
130
132
- var useKeyVault = useGPT4V || useSearchServiceKey
131
+ var useKeyVault = useSearchServiceKey
133
132
var tenantIdForAuth = !empty (authTenantId ) ? authTenantId : tenantId
134
133
var authenticationIssuerUri = '${environment ().authentication .loginEndpoint }${tenantIdForAuth }/v2.0'
135
134
@@ -182,7 +181,6 @@ module monitoring 'core/monitor/monitoring.bicep' = if (useApplicationInsights)
182
181
}
183
182
}
184
183
185
-
186
184
module applicationInsightsDashboard 'backend-dashboard.bicep' = if (useApplicationInsights ) {
187
185
name : 'application-insights-dashboard'
188
186
scope : resourceGroup
@@ -193,7 +191,6 @@ module applicationInsightsDashboard 'backend-dashboard.bicep' = if (useApplicati
193
191
}
194
192
}
195
193
196
-
197
194
// Create an App Service Plan to group applications under the same payment plan and SKU
198
195
module appServicePlan 'core/host/appserviceplan.bicep' = {
199
196
name : 'appserviceplan'
@@ -224,7 +221,7 @@ module backend 'core/host/appservice.bicep' = {
224
221
appCommandLine : 'python3 -m gunicorn main:app'
225
222
scmDoBuildDuringDeployment : true
226
223
managedIdentity : true
227
- allowedOrigins : [allowedOrigin ]
224
+ allowedOrigins : [ allowedOrigin ]
228
225
clientAppId : clientAppId
229
226
serverAppId : serverAppId
230
227
clientSecretSettingName : !empty (clientAppSecret ) ? 'AZURE_CLIENT_APP_SECRET' : ''
@@ -238,7 +235,6 @@ module backend 'core/host/appservice.bicep' = {
238
235
AZURE_SEARCH_SERVICE : searchService .outputs .name
239
236
AZURE_SEARCH_SEMANTIC_RANKER : actualSearchServiceSemanticRankerLevel
240
237
AZURE_VISION_ENDPOINT : useGPT4V ? computerVision .outputs .endpoint : ''
241
- VISION_SECRET_NAME : useGPT4V ? computerVisionSecretName : ''
242
238
SEARCH_SECRET_NAME : useSearchServiceKey ? searchServiceSecretName : ''
243
239
AZURE_KEY_VAULT_NAME : useKeyVault ? keyVault .outputs .name : ''
244
240
AZURE_SEARCH_QUERY_LANGUAGE : searchQueryLanguage
@@ -361,9 +357,8 @@ module computerVision 'core/ai/cognitiveservices.bicep' = if (useGPT4V) {
361
357
}
362
358
}
363
359
364
-
365
- // Currently, we only need Key Vault for storing Computer Vision key,
366
- // which is only used for GPT-4V.
360
+ // Currently, we only need Key Vault for storing Search service key,
361
+ // which is only used for free tier
367
362
module keyVault 'core/security/keyvault.bicep' = if (useKeyVault ) {
368
363
name : 'keyvault'
369
364
scope : keyVaultResourceGroup
@@ -388,16 +383,12 @@ module secrets 'secrets.bicep' = if (useKeyVault) {
388
383
scope : keyVaultResourceGroup
389
384
params : {
390
385
keyVaultName : useKeyVault ? keyVault .outputs .name : ''
391
- storeComputerVisionSecret : useGPT4V
392
- computerVisionId : useGPT4V ? computerVision .outputs .id : ''
393
- computerVisionSecretName : computerVisionSecretName
394
386
storeSearchServiceSecret : useSearchServiceKey
395
387
searchServiceId : useSearchServiceKey ? searchService .outputs .id : ''
396
388
searchServiceSecretName : searchServiceSecretName
397
389
}
398
390
}
399
391
400
-
401
392
module searchService 'core/search/search-services.bicep' = {
402
393
name : 'search-service'
403
394
scope : searchServiceResourceGroup
@@ -443,7 +434,7 @@ module storage 'core/storage/storage-account.bicep' = {
443
434
}
444
435
445
436
// USER ROLES
446
- var principalType = empty (runningOnGh ) && empty (runningOnAdo ) ? 'User' : 'ServicePrincipal'
437
+ var principalType = empty (runningOnGh ) && empty (runningOnAdo ) ? 'User' : 'ServicePrincipal'
447
438
448
439
module openAiRoleUser 'core/security/role.bicep' = if (openAiHost == 'azure' ) {
449
440
scope : openAiResourceGroup
@@ -455,9 +446,10 @@ module openAiRoleUser 'core/security/role.bicep' = if (openAiHost == 'azure') {
455
446
}
456
447
}
457
448
458
- module documentIntelligenceRoleUser 'core/security/role.bicep' = {
459
- scope : documentIntelligenceResourceGroup
460
- name : 'documentintelligence-role-user'
449
+ // For both document intelligence and computer vision
450
+ module cognitiveServicesRoleUser 'core/security/role.bicep' = {
451
+ scope : resourceGroup
452
+ name : 'cognitiveservices-role-user'
461
453
params : {
462
454
principalId : principalId
463
455
roleDefinitionId : 'a97b65f3-24c7-4388-baec-2e87135dc908'
@@ -537,7 +529,6 @@ module openAiRoleSearchService 'core/security/role.bicep' = if (openAiHost == 'a
537
529
}
538
530
}
539
531
540
-
541
532
module storageRoleBackend 'core/security/role.bicep' = {
542
533
scope : storageResourceGroup
543
534
name : 'storage-role-backend'
@@ -582,6 +573,17 @@ module searchReaderRoleBackend 'core/security/role.bicep' = if (useAuthenticatio
582
573
}
583
574
}
584
575
576
+ // For computer vision access by the backend
577
+ module cognitiveServicesRoleBackend 'core/security/role.bicep' = if (useGPT4V ) {
578
+ scope : resourceGroup
579
+ name : 'cognitiveservices-role-backend'
580
+ params : {
581
+ principalId : backend .outputs .identityPrincipalId
582
+ roleDefinitionId : 'a97b65f3-24c7-4388-baec-2e87135dc908'
583
+ principalType : 'ServicePrincipal'
584
+ }
585
+ }
586
+
585
587
output AZURE_LOCATION string = location
586
588
output AZURE_TENANT_ID string = tenantId
587
589
output AZURE_AUTH_TENANT_ID string = authTenantId
@@ -605,7 +607,6 @@ output OPENAI_API_KEY string = (openAiHost == 'openai') ? openAiApiKey : ''
605
607
output OPENAI_ORGANIZATION string = (openAiHost == 'openai' ) ? openAiApiOrganization : ''
606
608
607
609
output AZURE_VISION_ENDPOINT string = useGPT4V ? computerVision .outputs .endpoint : ''
608
- output VISION_SECRET_NAME string = useGPT4V ? computerVisionSecretName : ''
609
610
output AZURE_KEY_VAULT_NAME string = useKeyVault ? keyVault .outputs .name : ''
610
611
611
612
output AZURE_DOCUMENTINTELLIGENCE_SERVICE string = documentIntelligence .outputs .name
0 commit comments