@@ -112,6 +112,11 @@ resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
112112 }
113113}
114114
115+ resource existingAiFoundry 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' existing = if (!empty (azureExistingAIProjectResourceId )) {
116+ name : existingAIFoundryName
117+ scope : resourceGroup (existingAIServiceSubscription , existingAIServiceResourceGroup )
118+ }
119+
115120resource aiFoundry 'Microsoft.CognitiveServices/accounts@2025-04-01-preview' = if (empty (azureExistingAIProjectResourceId )) {
116121 name : aiFoundryName
117122 location : location
@@ -360,23 +365,27 @@ resource cogServiceEndpointEntry 'Microsoft.KeyVault/vaults/secrets@2021-11-01-p
360365 parent : keyVault
361366 name : 'COG-SERVICES-ENDPOINT'
362367 properties : {
363- value : aiFoundry .properties .endpoint
368+ value : !empty (existingOpenAIEndpoint )
369+ ? existingOpenAIEndpoint
370+ : aiFoundry .properties .endpoint
364371 }
365372}
366373
367374resource cogServiceKeyEntry 'Microsoft.KeyVault/vaults/secrets@2021-11-01-preview' = {
368375 parent : keyVault
369376 name : 'COG-SERVICES-KEY'
370377 properties : {
371- value : aiFoundry .listKeys ().key1
378+ value : !empty (existingOpenAIEndpoint )
379+ ? existingAiFoundry .listKeys ().key1
380+ : aiFoundry .listKeys ().key1
372381 }
373382}
374383
375384resource cogServiceNameEntry 'Microsoft.KeyVault/vaults/secrets@2021-11-01-preview' = {
376385 parent : keyVault
377386 name : 'COG-SERVICES-NAME'
378387 properties : {
379- value : aiFoundryName
388+ value : ! empty ( existingAIFoundryName ) ? existingAIFoundryName : aiFoundryName
380389 }
381390}
382391
@@ -407,9 +416,9 @@ resource azureLocatioEntry 'Microsoft.KeyVault/vaults/secrets@2021-11-01-preview
407416output keyvaultName string = keyvaultName
408417output keyvaultId string = keyVault .id
409418
410- output aiServicesTarget string = aiFoundry .properties .endpoint //aiServices_m.properties.endpoint
411- output aiServicesName string = aiFoundryName //aiServicesName_m
412- output aiServicesId string = aiFoundry .id //aiServices_m.id
419+ // output aiServicesTarget string = aiFoundry.properties.endpoint //aiServices_m.properties.endpoint
420+ // output aiServicesName string = aiFoundryName //aiServicesName_m
421+ // output aiServicesId string = aiFoundry.id //aiServices_m.id
413422
414423output aiSearchName string = aiSearchName
415424output aiSearchId string = aiSearch .id
@@ -426,6 +435,7 @@ output aoaiEndpoint string = !empty(existingOpenAIEndpoint)
426435 ? existingOpenAIEndpoint
427436 : aiFoundry .properties .endpoints ['OpenAI Language Model Instance API' ]
428437output aiFoundryName string = !empty (existingAIFoundryName ) ? existingAIFoundryName : aiFoundryName
438+ output aiFoundryRgName string = !empty (existingAIServiceResourceGroup ) ? existingAIServiceResourceGroup : resourceGroup ().name
429439
430440output applicationInsightsId string = applicationInsights .id
431441output logAnalyticsWorkspaceResourceName string = useExisting ? existingLogAnalyticsWorkspace .name : logAnalytics .name
0 commit comments