@@ -104,13 +104,13 @@ param tags resourceInput<'Microsoft.Resources/resourceGroups@2025-04-01'>.tags =
104104param enableMonitoring bool = true
105105
106106@description ('Optional. Enable scalability for applicable resources, aligned with the Well Architected Framework recommendations. Defaults to false.' )
107- param enableScalability bool = false
107+ param enableScalability bool = true
108108
109109@description ('Optional. Enable redundancy for applicable resources, aligned with the Well Architected Framework recommendations. Defaults to false.' )
110110param enableRedundancy bool = false
111111
112112@description ('Optional. Enable private networking for applicable resources, aligned with the Well Architected Framework recommendations. Defaults to false.' )
113- param enablePrivateNetworking bool = false
113+ param enablePrivateNetworking bool = true
114114
115115@description ('Optional. The Container Registry hostname where the docker images are located.' )
116116param acrName string = 'testapwaf'
@@ -207,7 +207,6 @@ resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = {
207207
208208// Extracts subscription, resource group, and workspace name from the resource ID when using an existing Log Analytics workspace
209209var useExistingLogAnalytics = !empty (existingLogAnalyticsWorkspaceId )
210- var logAnalyticsWorkspaceResourceId = useExistingLogAnalytics ? existingLogAnalyticsWorkspaceId : logAnalyticsWorkspace !.outputs .resourceId
211210
212211// ========== Log Analytics Workspace ========== //
213212var logAnalyticsWorkspaceResourceName = 'log-${solutionSuffix }'
@@ -269,10 +268,10 @@ module logAnalyticsWorkspace 'br/public:avm/res/operational-insights/workspace:0
269268 : null
270269 }
271270}
272-
271+ var logAnalyticsWorkspaceResourceId = useExistingLogAnalytics ? existingLogAnalyticsWorkspaceId : logAnalyticsWorkspace !. outputs . resourceId
273272// ========== Application Insights ========== //
274273var applicationInsightsResourceName = 'appi-${solutionSuffix }'
275- module applicationInsights 'br/public:avm/res/insights/component:0.6.0' = if (enableMonitoring ) {
274+ module applicationInsights 'br/public:avm/res/insights/component:0.6.0' = if (enableMonitoring && ! useExistingLogAnalytics ) {
276275 name : take ('avm.res.insights.component.${applicationInsightsResourceName }' , 64 )
277276 params : {
278277 name : applicationInsightsResourceName
@@ -284,8 +283,8 @@ module applicationInsights 'br/public:avm/res/insights/component:0.6.0' = if (en
284283 disableIpMasking : false
285284 flowType : 'Bluefield'
286285 // WAF aligned configuration for Monitoring
287- workspaceResourceId : enableMonitoring ? logAnalyticsWorkspace !. outputs . resourceId : ''
288- diagnosticSettings : enableMonitoring ? [{ workspaceResourceId : logAnalyticsWorkspace !. outputs . resourceId }] : null
286+ workspaceResourceId : enableMonitoring ? logAnalyticsWorkspaceResourceId : ''
287+ diagnosticSettings : enableMonitoring ? [{ workspaceResourceId : logAnalyticsWorkspaceResourceId }] : null
289288 }
290289}
291290
@@ -410,7 +409,7 @@ module keyvault 'br/public:avm/res/key-vault/vault:0.12.1' = {
410409 enablePurgeProtection : enablePurgeProtection
411410 softDeleteRetentionInDays : 7
412411 diagnosticSettings : enableMonitoring
413- ? [{ workspaceResourceId : logAnalyticsWorkspace !. outputs . resourceId }]
412+ ? [{ workspaceResourceId : logAnalyticsWorkspaceResourceId }]
414413 : []
415414 // WAF aligned configuration for Private Networking
416415 privateEndpoints : enablePrivateNetworking
@@ -648,9 +647,12 @@ module aiFoundryAiServicesProject 'modules/ai-project.bicep' = if (!useExistingA
648647 tags : tags
649648 desc : aiFoundryAiProjectDescription
650649 //Implicit dependencies below
651- aiServicesName : aiFoundryAiServices !. outputs . name
650+ aiServicesName : aiFoundryAiServicesResourceName
652651 azureExistingAIProjectResourceId : azureExistingAIProjectResourceId
653652 }
653+ dependsOn : [
654+ aiFoundryAiServices
655+ ]
654656}
655657
656658var aiFoundryAiProjectEndpoint = useExistingAiFoundryAiProject
@@ -716,12 +718,12 @@ module aiSearch 'br/public:avm/res/search/search-service:0.11.1' = {
716718 }
717719 {
718720 roleDefinitionIdOrName : '1407120a-92aa-4202-b7e9-c0e197c71c8f' // Search Index Data Reader
719- principalId : aiFoundryAiServicesProject !.outputs .systemAssignedMIPrincipalId
721+ principalId : ! useExistingAiFoundryAiProject ? aiFoundryAiServicesProject !.outputs .systemAssignedMIPrincipalId : existingAiFoundryAiServicesProject !. identity . principalId
720722 principalType : 'ServicePrincipal'
721723 }
722724 {
723725 roleDefinitionIdOrName : '7ca78c08-252a-4471-8644-bb5ff32d4ba0' // Search Service Contributor
724- principalId : aiFoundryAiServicesProject !.outputs .systemAssignedMIPrincipalId
726+ principalId : ! useExistingAiFoundryAiProject ? aiFoundryAiServicesProject !.outputs .systemAssignedMIPrincipalId : existingAiFoundryAiServicesProject !. identity . principalId
725727 principalType : 'ServicePrincipal'
726728 }
727729 ]
@@ -920,7 +922,7 @@ module cosmosDB 'br/public:avm/res/document-db/database-account:0.15.0' = {
920922 }
921923 ]
922924 // WAF aligned configuration for Monitoring
923- diagnosticSettings : enableMonitoring ? [{ workspaceResourceId : logAnalyticsWorkspace !. outputs . resourceId }] : null
925+ diagnosticSettings : enableMonitoring ? [{ workspaceResourceId : logAnalyticsWorkspaceResourceId }] : null
924926 // WAF aligned configuration for Private Networking
925927 networkRestrictions : {
926928 networkAclBypass : 'None'
@@ -1025,7 +1027,7 @@ module saveSecretsInKeyVault 'br/public:avm/res/key-vault/vault:0.12.1' = {
10251027 // }
10261028 {
10271029 name : 'COG-SERVICES-ENDPOINT'
1028- value : aiFoundryAiServicesProject !. outputs . aoaiEndpoint
1030+ value : 'https://${ aiFoundryAiServicesResourceName }.openai.azure.com/'
10291031 }
10301032 {name : 'AZURE-SEARCH-INDEX' , value : 'pdf_index' }
10311033 {
@@ -1039,7 +1041,7 @@ module saveSecretsInKeyVault 'br/public:avm/res/key-vault/vault:0.12.1' = {
10391041 {name : 'AZURE-OPENAI-EMBEDDING-MODEL' , value : embeddingModel }
10401042 {
10411043 name : 'AZURE-OPENAI-ENDPOINT'
1042- value : aiFoundryAiServicesProject !. outputs . aoaiEndpoint
1044+ value : 'https://${ aiFoundryAiServicesResourceName }.openai.azure.com/'
10431045 }
10441046 {name : 'AZURE-OPENAI-PREVIEW-API-VERSION' , value : azureOpenaiAPIVersion }
10451047 {name : 'AZURE-OPEN-AI-DEPLOYMENT-MODEL' , value : gptModelName }
@@ -1155,8 +1157,8 @@ module webSite 'modules/web-sites.bicep' = {
11551157 AZURE_SEARCH_CONNECTION_NAME : aiSearchConnectionName
11561158 AZURE_OPENAI_API_VERSION : azureOpenaiAPIVersion
11571159 AZURE_OPENAI_MODEL : gptModelName
1158- AZURE_OPENAI_ENDPOINT : aiFoundryAiServicesProject !. outputs . aoaiEndpoint
1159- AZURE_OPENAI_RESOURCE : aiFoundryAiServices !. outputs . name
1160+ AZURE_OPENAI_ENDPOINT : 'https://${ aiFoundryAiServicesResourceName }.openai.azure.com/'
1161+ AZURE_OPENAI_RESOURCE : aiFoundryAiServicesResourceName
11601162 AZURE_OPENAI_PREVIEW_API_VERSION : azureOpenaiAPIVersion
11611163 AZURE_OPENAI_GENERATE_SECTION_CONTENT_PROMPT : azureOpenAiGenerateSectionContentPrompt
11621164 AZURE_OPENAI_TEMPLATE_SYSTEM_MESSAGE : azureOpenAiTemplateSystemMessage
@@ -1178,7 +1180,7 @@ module webSite 'modules/web-sites.bicep' = {
11781180 AZURE_CLIENT_ID : userAssignedIdentity .outputs .clientId
11791181 }
11801182 // WAF aligned configuration for Monitoring
1181- applicationInsightResourceId : enableMonitoring ? applicationInsights !.outputs .resourceId : null
1183+ applicationInsightResourceId : ( enableMonitoring && ! useExistingLogAnalytics ) ? applicationInsights !.outputs .resourceId : null
11821184 }
11831185 ]
11841186 diagnosticSettings : enableMonitoring ? [{ workspaceResourceId : logAnalyticsWorkspaceResourceId }] : null
@@ -1235,13 +1237,13 @@ output cosmosDbAccountName string = cosmosDB.outputs.name
12351237output resourceGroupName string = resourceGroup ().name
12361238
12371239@description ('Contains AI Foundry Name' )
1238- output aiFoundryName string = aiFoundryAiServices !. outputs . name
1240+ output aiFoundryName string = aiFoundryAiServicesResourceName
12391241
12401242@description ('Contains AI Foundry RG Name' )
1241- output aiFoundryRgName string = aiFoundryAiServices !. outputs . resourceGroupName
1243+ output aiFoundryRgName string = aiFoundryAiServicesResourceGroupName
12421244
12431245@description ('Contains AI Foundry Resource ID' )
1244- output aiFoundryResourceId string = aiFoundryAiServices !.outputs .resourceId
1246+ output aiFoundryResourceId string = useExistingAiFoundryAiProject ? azureExistingAIProjectResourceId : aiFoundryAiServices !.outputs .resourceId
12451247
12461248@description ('Contains AI Search Service Name' )
12471249output aiSearchServiceName string = aiSearch .outputs .name
@@ -1265,10 +1267,10 @@ output azureOpenaiSystemMessage string = azureOpenAISystemMessage
12651267output azureOpenaiModel string = gptModelName
12661268
12671269@description ('Contains OpenAI Resource' )
1268- output azureOpenaiResource string = aiFoundryAiServices !. outputs . name
1270+ output azureOpenaiResource string = aiFoundryAiServicesResourceName
12691271
12701272@description ('Contains Azure Search Service' )
1271- output azureSearchService string = aiFoundryAiServices !. outputs . name
1273+ output azureSearchService string = aiFoundryAiServicesResourceName
12721274
12731275@description ('Contains Azure Search Index' )
12741276output azureSearchIndex string = 'pdf_index'
@@ -1292,7 +1294,7 @@ output azureSearchQueryType string = 'simple'
12921294output azureSearchVectorColumns string = 'contentVector'
12931295
12941296@description ('Contains AI Agent Endpoint' )
1295- output azureAiAgentEndpoint string = aiFoundryAiServicesProject !. outputs . apiEndpoint
1297+ output azureAiAgentEndpoint string = aiFoundryAiProjectEndpoint
12961298
12971299@description ('Contains AI Agent API Version' )
12981300output azureAiAgentApiVersion string = azureAiAgentApiVersion
@@ -1301,7 +1303,7 @@ output azureAiAgentApiVersion string = azureAiAgentApiVersion
13011303output azureAiAgentModelDeploymentName string = gptModelName
13021304
13031305@description ('Contains Application Insights Connection String' )
1304- output azureApplicationInsightsConnectionString string = enableMonitoring ? applicationInsights !.outputs .connectionString : ''
1306+ output azureApplicationInsightsConnectionString string = ( enableMonitoring && ! useExistingLogAnalytics ) ? applicationInsights !.outputs .connectionString : ''
13051307
13061308@description ('Contains Application Environment.' )
13071309output appEnv string = 'Prod'
0 commit comments