@@ -919,13 +919,15 @@ module virtualMachine 'br/public:avm/res/compute/virtual-machine:0.17.0' = if (e
919919}
920920
921921// ========== Private DNS Zones ========== //
922+ var keyVaultPrivateDNSZone = 'privatelink.${toLower (environment ().name ) == 'azureusgovernment' ? 'vaultcore.usgovcloudapi.net' : 'vaultcore.azure.net' }'
922923var privateDnsZones = [
923924 'privatelink.cognitiveservices.azure.com'
924925 'privatelink.openai.azure.com'
925926 'privatelink.services.ai.azure.com'
926927 'privatelink.documents.azure.com'
927928 'privatelink.blob.core.windows.net'
928929 'privatelink.search.windows.net'
930+ keyVaultPrivateDNSZone
929931]
930932
931933// DNS Zone Index Constants
@@ -936,6 +938,7 @@ var dnsZoneIndex = {
936938 cosmosDb : 3
937939 blob : 4
938940 search : 5
941+ keyVault : 6
939942}
940943
941944// List of DNS zone indices that correspond to AI-related services.
@@ -1483,7 +1486,7 @@ module containerApp 'br/public:avm/res/app/container-app:0.18.1' = {
14831486 }
14841487 {
14851488 name : 'AZURE_AI_SEARCH_API_KEY'
1486- value : ''
1489+ secretRef : 'azure-ai-search-api-key '
14871490 }
14881491 {
14891492 name : 'BING_CONNECTION_NAME'
@@ -1498,6 +1501,14 @@ module containerApp 'br/public:avm/res/app/container-app:0.18.1' = {
14981501 value : storageContainerName
14991502 }
15001503 ]
1504+
1505+ }
1506+ ]
1507+ secrets : [
1508+ {
1509+ name : 'azure-ai-search-api-key'
1510+ keyVaultUrl : keyvault .outputs .secrets [0 ].uriWithVersion
1511+ identity : userAssignedIdentity .outputs .resourceId
15011512 }
15021513 ]
15031514 }
@@ -1838,13 +1849,68 @@ module aiSearchFoundryConnection 'modules/aifp-connections.bicep' = {
18381849 searchServiceResourceId : searchService .outputs .resourceId
18391850 searchServiceLocation : searchService .outputs .location
18401851 searchServiceName : searchService .outputs .name
1852+ searchApiKey : searchService .outputs .primaryKey
18411853 }
18421854 dependsOn : [
18431855 aiFoundryAiServices
18441856 ]
18451857}
18461858
18471859
1860+ // ========== KeyVault ========== //
1861+ var keyVaultName = 'kv-${solutionSuffix }'
1862+ module keyvault 'br/public:avm/res/key-vault/vault:0.12.1' = {
1863+ name : take ('avm.res.key-vault.vault.${keyVaultName }' , 64 )
1864+ params : {
1865+ name : keyVaultName
1866+ location : location
1867+ tags : tags
1868+ sku : enableScalability ? 'premium' : 'standard'
1869+ publicNetworkAccess : enablePrivateNetworking ? 'Disabled' : 'Enabled'
1870+ networkAcls : {
1871+ defaultAction : 'Allow'
1872+ }
1873+ enableVaultForDeployment : true
1874+ enableVaultForDiskEncryption : true
1875+ enableVaultForTemplateDeployment : true
1876+ enableRbacAuthorization : true
1877+ enableSoftDelete : true
1878+ softDeleteRetentionInDays : 7
1879+ diagnosticSettings : enableMonitoring
1880+ ? [{ workspaceResourceId : logAnalyticsWorkspace !.outputs .resourceId }]
1881+ : []
1882+ // WAF aligned configuration for Private Networking
1883+ privateEndpoints : enablePrivateNetworking
1884+ ? [
1885+ {
1886+ name : 'pep-${keyVaultName }'
1887+ customNetworkInterfaceName : 'nic-${keyVaultName }'
1888+ privateDnsZoneGroup : {
1889+ privateDnsZoneGroupConfigs : [{ privateDnsZoneResourceId : avmPrivateDnsZones [dnsZoneIndex .keyVault ]!.outputs .resourceId }]
1890+ }
1891+ service : 'vault'
1892+ subnetResourceId : virtualNetwork !.outputs .subnetResourceIds [0 ]
1893+ }
1894+ ]
1895+ : []
1896+ // WAF aligned configuration for Role-based Access Control
1897+ roleAssignments : [
1898+ {
1899+ principalId : userAssignedIdentity .outputs .principalId
1900+ principalType : 'ServicePrincipal'
1901+ roleDefinitionIdOrName : 'Key Vault Administrator'
1902+ }
1903+ ]
1904+ secrets : [
1905+ {
1906+ name : 'AzureAISearchAPIKey'
1907+ value : searchService .outputs .primaryKey
1908+ }
1909+ ]
1910+ enableTelemetry : enableTelemetry
1911+ }
1912+ }
1913+
18481914// ============ //
18491915// Outputs //
18501916// ============ //
@@ -1890,3 +1956,4 @@ output REASONING_MODEL_NAME string = 'o3'
18901956output MCP_SERVER_NAME string = 'MACAE MCP Server'
18911957output MCP_SERVER_DESCRIPTION string = 'MACAE MCP Server Description'
18921958output SUPPORTED_MODELS string = '["o3","o4-mini","gpt-4.1","gpt-4.1-mini"]'
1959+ output AZURE_AI_SEARCH_API_KEY string = '<Deployed-Search-ApiKey>'
0 commit comments