@@ -893,21 +893,30 @@ module virtualMachine 'br/public:avm/res/compute/virtual-machine:0.17.0' = if (e
893893 }
894894}
895895
896- // ========== AI Foundry: AI Services ========== //
897- // WAF best practices for Open AI: https://learn.microsoft.com/en-us/azure/well-architected/service-guides/azure-openai
898- var openAiSubResource = 'account'
899- var openAiPrivateDnsZones = {
900- 'privatelink.cognitiveservices.azure.com' : openAiSubResource
901- 'privatelink.openai.azure.com' : openAiSubResource
902- 'privatelink.services.ai.azure.com' : openAiSubResource
896+ // ========== Private DNS Zones ========== //
897+ var privateDnsZones = [
898+ 'privatelink.cognitiveservices.azure.com'
899+ 'privatelink.openai.azure.com'
900+ 'privatelink.services.ai.azure.com'
901+ 'privatelink.documents.azure.com'
902+ 'privatelink.${toLower (replace (location ,' ' ,'' ))}.azurecontainerapps.io'
903+ 'privatelink.azurewebsites.net'
904+ ]
905+
906+ // DNS Zone Index Constants
907+ var dnsZoneIndex = {
908+ cognitiveServices : 0
909+ openAI : 1
910+ aiServices : 2
911+ cosmosDb : 3
912+ containerAppEnvironment : 4
913+ appService : 5
903914}
904915
905- module privateDnsZonesAiServices 'br/public:avm/res/network/private-dns-zone:0.7.1' = [
906- for zone in objectKeys (openAiPrivateDnsZones ): if (enablePrivateNetworking ) {
907- name : take (
908- 'avm.res.network.private-dns-zone.ai-services.${uniqueString (aiFoundryAiServicesResourceName ,zone )}.${solutionSuffix }' ,
909- 64
910- )
916+ @batchSize (5 )
917+ module avmPrivateDnsZones 'br/public:avm/res/network/private-dns-zone:0.7.1' = [
918+ for (zone , i ) in privateDnsZones : if (enablePrivateNetworking ) {
919+ name : 'avm.res.network.private-dns-zone.${i }'
911920 params : {
912921 name : zone
913922 tags : tags
@@ -922,6 +931,9 @@ module privateDnsZonesAiServices 'br/public:avm/res/network/private-dns-zone:0.7
922931 }
923932]
924933
934+ // ========== AI Foundry: AI Services ========== //
935+ // WAF best practices for Open AI: https://learn.microsoft.com/en-us/azure/well-architected/service-guides/azure-openai
936+
925937// NOTE: Required version 'Microsoft.CognitiveServices/accounts@2024-04-01-preview' not available in AVM
926938var aiFoundryAiServicesResourceName = 'aif-${solutionSuffix }'
927939var aiFoundryAiServicesAiProjectResourceName = 'proj-${solutionSuffix }'
@@ -986,10 +998,20 @@ module aiFoundryAiServices 'modules/ai-services.bicep' = if (aiFoundryAIservices
986998 customNetworkInterfaceName : 'nic-${aiFoundryAiServicesResourceName }'
987999 subnetResourceId : virtualNetwork !.outputs .subnetResourceIds [0 ]
9881000 privateDnsZoneGroup : {
989- privateDnsZoneGroupConfigs : map (objectKeys (openAiPrivateDnsZones ), zone => {
990- name : replace (zone , '.' , '-' )
991- privateDnsZoneResourceId : resourceId ('Microsoft.Network/privateDnsZones' , zone )
992- })
1001+ privateDnsZoneGroupConfigs : [
1002+ {
1003+ name : 'ai-services-dns-zone-cognitiveservices'
1004+ privateDnsZoneResourceId : avmPrivateDnsZones [dnsZoneIndex .cognitiveServices ]!.outputs .resourceId
1005+ }
1006+ {
1007+ name : 'ai-services-dns-zone-openai'
1008+ privateDnsZoneResourceId : avmPrivateDnsZones [dnsZoneIndex .openAI ]!.outputs .resourceId
1009+ }
1010+ {
1011+ name : 'ai-services-dns-zone-aiservices'
1012+ privateDnsZoneResourceId : avmPrivateDnsZones [dnsZoneIndex .aiServices ]!.outputs .resourceId
1013+ }
1014+ ]
9931015 }
9941016 }
9951017 ])
@@ -1051,20 +1073,6 @@ module resourceRoleAssignmentAiServicesAiProjectCognitiveServicesOpenAiUser 'br/
10511073
10521074// ========== Cosmos DB ========== //
10531075// WAF best practices for Cosmos DB: https://learn.microsoft.com/en-us/azure/well-architected/service-guides/cosmos-db
1054- module privateDnsZonesCosmosDb 'br/public:avm/res/network/private-dns-zone:0.7.1' = if (enablePrivateNetworking ) {
1055- name : take ('avm.res.network.private-dns-zone.cosmos-db.${solutionSuffix }' , 64 )
1056- params : {
1057- name : 'privatelink.documents.azure.com'
1058- enableTelemetry : enableTelemetry
1059- virtualNetworkLinks : [
1060- {
1061- name : take ('vnetlink-${virtualNetworkResourceName }-documents' , 80 )
1062- virtualNetworkResourceId : virtualNetwork !.outputs .resourceId
1063- }
1064- ]
1065- tags : tags
1066- }
1067- }
10681076
10691077var cosmosDbResourceName = 'cosmos-${solutionSuffix }'
10701078var cosmosDbDatabaseName = 'macae'
@@ -1119,7 +1127,7 @@ module cosmosDb 'br/public:avm/res/document-db/database-account:0.15.0' = {
11191127 name : 'pep-${cosmosDbResourceName }'
11201128 customNetworkInterfaceName : 'nic-${cosmosDbResourceName }'
11211129 privateDnsZoneGroup : {
1122- privateDnsZoneGroupConfigs : [{ privateDnsZoneResourceId : privateDnsZonesCosmosDb !.outputs .resourceId }]
1130+ privateDnsZoneGroupConfigs : [{ privateDnsZoneResourceId : avmPrivateDnsZones [ dnsZoneIndex . cosmosDb ] !.outputs .resourceId }]
11231131 }
11241132 service : 'Sql'
11251133 subnetResourceId : virtualNetwork !.outputs .subnetResourceIds [0 ]
@@ -1199,16 +1207,7 @@ module containerAppEnvironment 'br/public:avm/res/app/managed-environment:0.11.2
11991207 }
12001208}
12011209
1202- // Private DNS Zone Group for Container App Environment Private Endpoint
1203- module privateDnsZonesContainerAppEnvironment 'br/public:avm/res/network/private-dns-zone:0.7.1' = if (enablePrivateNetworking ) {
1204- name : take ('avm.res.network.private-dns-zone.app-environment.${solutionSuffix }' , 64 )
1205- params : {
1206- name : 'privatelink.${toLower (replace (containerAppEnvironment .outputs .location ,' ' ,'' ))}.azurecontainerapps.io'
1207- enableTelemetry : enableTelemetry
1208- virtualNetworkLinks : [{ virtualNetworkResourceId : virtualNetwork !.outputs .resourceId }]
1209- tags : tags
1210- }
1211- }
1210+
12121211
12131212// Private Endpoint for Container App Environment
12141213var privateEndpointContainerAppEnvironmentService = 'managedEnvironments'
@@ -1233,7 +1232,7 @@ module privateEndpointContainerAppEnvironment 'br:mcr.microsoft.com/bicep/avm/re
12331232 ]
12341233 privateDnsZoneGroup : {
12351234 privateDnsZoneGroupConfigs : [
1236- { privateDnsZoneResourceId : privateDnsZonesContainerAppEnvironment !.outputs .resourceId }
1235+ { privateDnsZoneResourceId : avmPrivateDnsZones [ dnsZoneIndex . containerAppEnvironment ] !.outputs .resourceId }
12371236 ]
12381237 }
12391238 }
@@ -1245,6 +1244,9 @@ module privateEndpointContainerAppEnvironment 'br:mcr.microsoft.com/bicep/avm/re
12451244var containerAppResourceName = 'ca-${solutionSuffix }'
12461245module containerApp 'br/public:avm/res/app/container-app:0.18.1' = {
12471246 name : take ('avm.res.app.container-app.${containerAppResourceName }' , 64 )
1247+ dependsOn :[
1248+ privateEndpointContainerAppEnvironment
1249+ ]
12481250 params : {
12491251 name : containerAppResourceName
12501252 tags : tags
@@ -1399,16 +1401,6 @@ module webServerFarm 'br/public:avm/res/web/serverfarm:0.5.0' = {
13991401// ========== Frontend web site ========== //
14001402// WAF best practices for web app service: https://learn.microsoft.com/en-us/azure/well-architected/service-guides/app-service-web-apps
14011403// PSRule for Web Server Farm: https://azure.github.io/PSRule.Rules.Azure/en/rules/resource/#app-service
1402- // Private DNS Zone Group for Web App Service Private Endpoint
1403- module privateDnsZonesWebApp 'br/public:avm/res/network/private-dns-zone:0.7.1' = if (enablePrivateNetworking ) {
1404- name : take ('avm.res.network.private-dns-zone.web-app.${solutionSuffix }' , 64 )
1405- params : {
1406- name : 'privatelink.azurewebsites.net'
1407- enableTelemetry : enableTelemetry
1408- virtualNetworkLinks : [{ virtualNetworkResourceId : virtualNetwork !.outputs .resourceId }]
1409- tags : tags
1410- }
1411- }
14121404
14131405//NOTE: AVM module adds 1 MB of overhead to the template. Keeping vanilla resource to save template size.
14141406var webSiteResourceName = 'app-${solutionSuffix }'
@@ -1451,7 +1443,7 @@ module webSite 'modules/web-sites.bicep' = {
14511443 name : 'pep-${webSiteResourceName }'
14521444 customNetworkInterfaceName : 'nic-${webSiteResourceName }'
14531445 privateDnsZoneGroup : {
1454- privateDnsZoneGroupConfigs : [{ privateDnsZoneResourceId : privateDnsZonesWebApp !.outputs .resourceId }]
1446+ privateDnsZoneGroupConfigs : [{ privateDnsZoneResourceId : avmPrivateDnsZones [ dnsZoneIndex . appService ] !.outputs .resourceId }]
14551447 }
14561448 service : 'sites'
14571449 subnetResourceId : virtualNetwork !.outputs .subnetResourceIds [0 ]
0 commit comments