@@ -946,13 +946,15 @@ module virtualMachine 'br/public:avm/res/compute/virtual-machine:0.17.0' = if (e
946946}
947947
948948// ========== Private DNS Zones ========== //
949+ var keyVaultPrivateDNSZone = 'privatelink.${toLower (environment ().name ) == 'azureusgovernment' ? 'vaultcore.usgovcloudapi.net' : 'vaultcore.azure.net' }'
949950var privateDnsZones = [
950951 'privatelink.cognitiveservices.azure.com'
951952 'privatelink.openai.azure.com'
952953 'privatelink.services.ai.azure.com'
953954 'privatelink.documents.azure.com'
954955 'privatelink.blob.core.windows.net'
955956 'privatelink.search.windows.net'
957+ keyVaultPrivateDNSZone
956958]
957959
958960// DNS Zone Index Constants
@@ -963,6 +965,7 @@ var dnsZoneIndex = {
963965 cosmosDb : 3
964966 blob : 4
965967 search : 5
968+ keyVault : 6
966969}
967970
968971// List of DNS zone indices that correspond to AI-related services.
@@ -1550,7 +1553,7 @@ module containerApp 'br/public:avm/res/app/container-app:0.18.1' = {
15501553 }
15511554 {
15521555 name : 'AZURE_AI_SEARCH_API_KEY'
1553- value : ''
1556+ secretRef : 'azure-ai-search-api-key '
15541557 }
15551558 {
15561559 name : 'BING_CONNECTION_NAME'
@@ -1569,6 +1572,14 @@ module containerApp 'br/public:avm/res/app/container-app:0.18.1' = {
15691572 value : aiFoundryAiServicesModelDeployment .name
15701573 }
15711574 ]
1575+
1576+ }
1577+ ]
1578+ secrets : [
1579+ {
1580+ name : 'azure-ai-search-api-key'
1581+ keyVaultUrl : keyvault .outputs .secrets [0 ].uriWithVersion
1582+ identity : userAssignedIdentity .outputs .resourceId
15721583 }
15731584 ]
15741585 }
@@ -1909,13 +1920,68 @@ module aiSearchFoundryConnection 'modules/aifp-connections.bicep' = {
19091920 searchServiceResourceId : searchService .outputs .resourceId
19101921 searchServiceLocation : searchService .outputs .location
19111922 searchServiceName : searchService .outputs .name
1923+ searchApiKey : searchService .outputs .primaryKey
19121924 }
19131925 dependsOn : [
19141926 aiFoundryAiServices
19151927 ]
19161928}
19171929
19181930
1931+ // ========== KeyVault ========== //
1932+ var keyVaultName = 'kv-${solutionSuffix }'
1933+ module keyvault 'br/public:avm/res/key-vault/vault:0.12.1' = {
1934+ name : take ('avm.res.key-vault.vault.${keyVaultName }' , 64 )
1935+ params : {
1936+ name : keyVaultName
1937+ location : location
1938+ tags : tags
1939+ sku : enableScalability ? 'premium' : 'standard'
1940+ publicNetworkAccess : enablePrivateNetworking ? 'Disabled' : 'Enabled'
1941+ networkAcls : {
1942+ defaultAction : 'Allow'
1943+ }
1944+ enableVaultForDeployment : true
1945+ enableVaultForDiskEncryption : true
1946+ enableVaultForTemplateDeployment : true
1947+ enableRbacAuthorization : true
1948+ enableSoftDelete : true
1949+ softDeleteRetentionInDays : 7
1950+ diagnosticSettings : enableMonitoring
1951+ ? [{ workspaceResourceId : logAnalyticsWorkspace !.outputs .resourceId }]
1952+ : []
1953+ // WAF aligned configuration for Private Networking
1954+ privateEndpoints : enablePrivateNetworking
1955+ ? [
1956+ {
1957+ name : 'pep-${keyVaultName }'
1958+ customNetworkInterfaceName : 'nic-${keyVaultName }'
1959+ privateDnsZoneGroup : {
1960+ privateDnsZoneGroupConfigs : [{ privateDnsZoneResourceId : avmPrivateDnsZones [dnsZoneIndex .keyVault ]!.outputs .resourceId }]
1961+ }
1962+ service : 'vault'
1963+ subnetResourceId : virtualNetwork !.outputs .subnetResourceIds [0 ]
1964+ }
1965+ ]
1966+ : []
1967+ // WAF aligned configuration for Role-based Access Control
1968+ roleAssignments : [
1969+ {
1970+ principalId : userAssignedIdentity .outputs .principalId
1971+ principalType : 'ServicePrincipal'
1972+ roleDefinitionIdOrName : 'Key Vault Administrator'
1973+ }
1974+ ]
1975+ secrets : [
1976+ {
1977+ name : 'AzureAISearchAPIKey'
1978+ value : searchService .outputs .primaryKey
1979+ }
1980+ ]
1981+ enableTelemetry : enableTelemetry
1982+ }
1983+ }
1984+
19191985// ============ //
19201986// Outputs //
19211987// ============ //
@@ -1961,3 +2027,4 @@ output REASONING_MODEL_NAME string = aiFoundryAiServicesReasoningModelDeployment
19612027output MCP_SERVER_NAME string = 'MACAE MCP Server'
19622028output MCP_SERVER_DESCRIPTION string = 'MACAE MCP Server Description'
19632029output SUPPORTED_MODELS string = '["o3","o4-mini","gpt-4.1","gpt-4.1-mini"]'
2030+ output AZURE_AI_SEARCH_API_KEY string = '<Deployed-Search-ApiKey>'
0 commit comments