@@ -31,7 +31,6 @@ var actualSearchServiceSemanticRankerLevel = (searchServiceSkuName == 'free') ?
3131param useSearchServiceKey bool = searchServiceSkuName == 'free'
3232
3333param storageAccountName string = ''
34- param keyVaultResourceGroupName string = ''
3534param storageResourceGroupName string = ''
3635param storageResourceGroupLocation string = location
3736param storageContainerName string = 'content'
@@ -47,12 +46,12 @@ param openAiServiceName string = ''
4746param openAiResourceGroupName string = ''
4847param useGPT4V bool = false
4948
49+ param keyVaultResourceGroupName string = ''
5050param keyVaultServiceName string = ''
51- param computerVisionSecretName string = 'computerVisionSecret'
5251param searchServiceSecretName string = 'searchServiceSecret'
5352
5453@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' ])
5655@metadata ({
5756 azd : {
5857 type : 'location'
@@ -70,7 +69,7 @@ param documentIntelligenceResourceGroupName string = ''
7069// Limited regions for new version:
7170// https://learn.microsoft.com/azure/ai-services/document-intelligence/concept-layout
7271@description ('Location for the Document Intelligence resource group' )
73- @allowed (['eastus' , 'westus2' , 'westeurope' ])
72+ @allowed ([ 'eastus' , 'westus2' , 'westeurope' ])
7473@metadata ({
7574 azd : {
7675 type : 'location'
@@ -129,7 +128,7 @@ var resourceToken = toLower(uniqueString(subscription().id, environmentName, loc
129128var tags = { 'azd-env-name' : environmentName }
130129var computerVisionName = !empty (computerVisionServiceName ) ? computerVisionServiceName : '${abbrs .cognitiveServicesComputerVision }${resourceToken }'
131130
132- var useKeyVault = useGPT4V || useSearchServiceKey
131+ var useKeyVault = useSearchServiceKey
133132var tenantIdForAuth = !empty (authTenantId ) ? authTenantId : tenantId
134133var authenticationIssuerUri = '${environment ().authentication .loginEndpoint }${tenantIdForAuth }/v2.0'
135134
@@ -182,7 +181,6 @@ module monitoring 'core/monitor/monitoring.bicep' = if (useApplicationInsights)
182181 }
183182}
184183
185-
186184module applicationInsightsDashboard 'backend-dashboard.bicep' = if (useApplicationInsights ) {
187185 name : 'application-insights-dashboard'
188186 scope : resourceGroup
@@ -193,7 +191,6 @@ module applicationInsightsDashboard 'backend-dashboard.bicep' = if (useApplicati
193191 }
194192}
195193
196-
197194// Create an App Service Plan to group applications under the same payment plan and SKU
198195module appServicePlan 'core/host/appserviceplan.bicep' = {
199196 name : 'appserviceplan'
@@ -224,7 +221,7 @@ module backend 'core/host/appservice.bicep' = {
224221 appCommandLine : 'python3 -m gunicorn main:app'
225222 scmDoBuildDuringDeployment : true
226223 managedIdentity : true
227- allowedOrigins : [allowedOrigin ]
224+ allowedOrigins : [ allowedOrigin ]
228225 clientAppId : clientAppId
229226 serverAppId : serverAppId
230227 clientSecretSettingName : !empty (clientAppSecret ) ? 'AZURE_CLIENT_APP_SECRET' : ''
@@ -238,7 +235,6 @@ module backend 'core/host/appservice.bicep' = {
238235 AZURE_SEARCH_SERVICE : searchService .outputs .name
239236 AZURE_SEARCH_SEMANTIC_RANKER : actualSearchServiceSemanticRankerLevel
240237 AZURE_VISION_ENDPOINT : useGPT4V ? computerVision .outputs .endpoint : ''
241- VISION_SECRET_NAME : useGPT4V ? computerVisionSecretName : ''
242238 SEARCH_SECRET_NAME : useSearchServiceKey ? searchServiceSecretName : ''
243239 AZURE_KEY_VAULT_NAME : useKeyVault ? keyVault .outputs .name : ''
244240 AZURE_SEARCH_QUERY_LANGUAGE : searchQueryLanguage
@@ -361,9 +357,8 @@ module computerVision 'core/ai/cognitiveservices.bicep' = if (useGPT4V) {
361357 }
362358}
363359
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
367362module keyVault 'core/security/keyvault.bicep' = if (useKeyVault ) {
368363 name : 'keyvault'
369364 scope : keyVaultResourceGroup
@@ -388,16 +383,12 @@ module secrets 'secrets.bicep' = if (useKeyVault) {
388383 scope : keyVaultResourceGroup
389384 params : {
390385 keyVaultName : useKeyVault ? keyVault .outputs .name : ''
391- storeComputerVisionSecret : useGPT4V
392- computerVisionId : useGPT4V ? computerVision .outputs .id : ''
393- computerVisionSecretName : computerVisionSecretName
394386 storeSearchServiceSecret : useSearchServiceKey
395387 searchServiceId : useSearchServiceKey ? searchService .outputs .id : ''
396388 searchServiceSecretName : searchServiceSecretName
397389 }
398390}
399391
400-
401392module searchService 'core/search/search-services.bicep' = {
402393 name : 'search-service'
403394 scope : searchServiceResourceGroup
@@ -443,7 +434,7 @@ module storage 'core/storage/storage-account.bicep' = {
443434}
444435
445436// USER ROLES
446- var principalType = empty (runningOnGh ) && empty (runningOnAdo ) ? 'User' : 'ServicePrincipal'
437+ var principalType = empty (runningOnGh ) && empty (runningOnAdo ) ? 'User' : 'ServicePrincipal'
447438
448439module openAiRoleUser 'core/security/role.bicep' = if (openAiHost == 'azure' ) {
449440 scope : openAiResourceGroup
@@ -455,9 +446,10 @@ module openAiRoleUser 'core/security/role.bicep' = if (openAiHost == 'azure') {
455446 }
456447}
457448
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'
461453 params : {
462454 principalId : principalId
463455 roleDefinitionId : 'a97b65f3-24c7-4388-baec-2e87135dc908'
@@ -537,7 +529,6 @@ module openAiRoleSearchService 'core/security/role.bicep' = if (openAiHost == 'a
537529 }
538530}
539531
540-
541532module storageRoleBackend 'core/security/role.bicep' = {
542533 scope : storageResourceGroup
543534 name : 'storage-role-backend'
@@ -582,6 +573,17 @@ module searchReaderRoleBackend 'core/security/role.bicep' = if (useAuthenticatio
582573 }
583574}
584575
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+
585587output AZURE_LOCATION string = location
586588output AZURE_TENANT_ID string = tenantId
587589output AZURE_AUTH_TENANT_ID string = authTenantId
@@ -605,7 +607,6 @@ output OPENAI_API_KEY string = (openAiHost == 'openai') ? openAiApiKey : ''
605607output OPENAI_ORGANIZATION string = (openAiHost == 'openai' ) ? openAiApiOrganization : ''
606608
607609output AZURE_VISION_ENDPOINT string = useGPT4V ? computerVision .outputs .endpoint : ''
608- output VISION_SECRET_NAME string = useGPT4V ? computerVisionSecretName : ''
609610output AZURE_KEY_VAULT_NAME string = useKeyVault ? keyVault .outputs .name : ''
610611
611612output AZURE_DOCUMENTINTELLIGENCE_SERVICE string = documentIntelligence .outputs .name
0 commit comments