Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,17 @@ module cognitiveServicesCu 'br/public:avm/res/cognitive-services/account:0.14.1'
// ========== AVM WAF ========== //
// ========== AI Foundry: AI Search ========== //
var aiSearchName = 'srch-${solutionSuffix}'
module searchSearchServices 'br/public:avm/res/search/search-service:0.12.0' = {
name: take('avm.res.search.search-service.${aiSearchName}', 64)
resource searchService 'Microsoft.Search/searchServices@2024-06-01-preview' = {
name: aiSearchName
location: location
sku: {
name: 'standard'
}
}

// Separate module for Search Service to enable managed identity and update other properties, as this reduces deployment time
module searchServiceUpdate 'br/public:avm/res/search/search-service:0.12.0' = {
name: take('avm.res.search.enable-identity.${aiSearchName}', 64)
params: {
// Required parameters
name: aiSearchName
Expand Down Expand Up @@ -822,14 +831,17 @@ module searchSearchServices 'br/public:avm/res/search/search-service:0.12.0' = {
]
: []
}
dependsOn: [
searchService
]
}

// ========== Search Service to AI Services Role Assignment ========== //
resource searchServiceToAiServicesRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (!useExistingAiFoundryAiProject) {
name: guid(aiSearchName, '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd', aiFoundryAiServicesResourceName)
properties: {
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd') // Cognitive Services OpenAI User
principalId: searchSearchServices.outputs.systemAssignedMIPrincipalId!
principalId: searchServiceUpdate.outputs.systemAssignedMIPrincipalId!
principalType: 'ServicePrincipal'
}
}
Expand All @@ -843,10 +855,13 @@ resource projectAISearchConnection 'Microsoft.CognitiveServices/accounts/project
isSharedToAll: true
metadata: {
ApiType: 'Azure'
ResourceId: searchSearchServices.outputs.resourceId
location: searchSearchServices.outputs.location
ResourceId: searchService.id
location: searchService.location
}
}
dependsOn: [
aiFoundryAiServices
]
}

module existing_AIProject_SearchConnectionModule 'modules/deploy_aifp_aisearch_connection.bicep' = if (useExistingAiFoundryAiProject) {
Expand All @@ -856,8 +871,8 @@ module existing_AIProject_SearchConnectionModule 'modules/deploy_aifp_aisearch_c
existingAIProjectName: aiFoundryAiProjectResourceName
existingAIFoundryName: aiFoundryAiServicesResourceName
aiSearchName: aiSearchName
aiSearchResourceId: searchSearchServices.outputs.resourceId
aiSearchLocation: searchSearchServices.outputs.location
aiSearchResourceId: searchService.id
aiSearchLocation: searchService.location
aiSearchConnectionName: aiSearchName
}
}
Expand All @@ -867,7 +882,7 @@ module searchServiceToExistingAiServicesRoleAssignment 'modules/role-assignment.
name: 'searchToExistingAiServices-roleAssignment'
scope: resourceGroup(aiFoundryAiServicesSubscriptionId, aiFoundryAiServicesResourceGroupName)
params: {
principalId: searchSearchServices.outputs.systemAssignedMIPrincipalId!
principalId: searchServiceUpdate.outputs.systemAssignedMIPrincipalId!
roleDefinitionId: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd' // Cognitive Services OpenAI User
targetResourceName: aiFoundryAiServices.outputs.name
}
Expand Down
43 changes: 27 additions & 16 deletions infra/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.40.2.10011",
"templateHash": "13633343500956336860"
"templateHash": "11209346631275672110"
}
},
"parameters": {
Expand Down Expand Up @@ -465,18 +465,27 @@
"resourceGroup": "[variables('aiFoundryAiServicesResourceGroupName')]",
"name": "[format('{0}/{1}', variables('aiFoundryAiServicesResourceName'), variables('aiFoundryAiProjectResourceName'))]"
},
"searchService": {
"type": "Microsoft.Search/searchServices",
"apiVersion": "2024-06-01-preview",
"name": "[variables('aiSearchName')]",
"location": "[parameters('location')]",
"sku": {
"name": "standard"
}
},
"searchServiceToAiServicesRoleAssignment": {
"condition": "[not(variables('useExistingAiFoundryAiProject'))]",
"type": "Microsoft.Authorization/roleAssignments",
"apiVersion": "2022-04-01",
"name": "[guid(variables('aiSearchName'), '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd', variables('aiFoundryAiServicesResourceName'))]",
"properties": {
"roleDefinitionId": "[subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd')]",
"principalId": "[reference('searchSearchServices').outputs.systemAssignedMIPrincipalId.value]",
"principalId": "[reference('searchServiceUpdate').outputs.systemAssignedMIPrincipalId.value]",
"principalType": "ServicePrincipal"
},
"dependsOn": [
"searchSearchServices"
"searchServiceUpdate"
]
},
"projectAISearchConnection": {
Expand All @@ -491,12 +500,13 @@
"isSharedToAll": true,
"metadata": {
"ApiType": "Azure",
"ResourceId": "[reference('searchSearchServices').outputs.resourceId.value]",
"location": "[reference('searchSearchServices').outputs.location.value]"
"ResourceId": "[resourceId('Microsoft.Search/searchServices', variables('aiSearchName'))]",
"location": "[reference('searchService', '2024-06-01-preview', 'full').location]"
}
},
"dependsOn": [
"searchSearchServices"
"aiFoundryAiServices",
"searchService"
]
},
"logAnalyticsWorkspace": {
Expand Down Expand Up @@ -27516,9 +27526,9 @@
}
},
"dependsOn": [
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').cognitiveServices)]",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').openAI)]",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]",
"backendUserAssignedIdentity",
"logAnalyticsWorkspace",
"userAssignedIdentity",
Expand Down Expand Up @@ -30041,18 +30051,18 @@
}
},
"dependsOn": [
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').cognitiveServices)]",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').openAI)]",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]",
"logAnalyticsWorkspace",
"userAssignedIdentity",
"virtualNetwork"
]
},
"searchSearchServices": {
"searchServiceUpdate": {
"type": "Microsoft.Resources/deployments",
"apiVersion": "2025-04-01",
"name": "[take(format('avm.res.search.search-service.{0}', variables('aiSearchName')), 64)]",
"name": "[take(format('avm.res.search.enable-identity.{0}', variables('aiSearchName')), 64)]",
"properties": {
"expressionEvaluationOptions": {
"scope": "inner"
Expand Down Expand Up @@ -32180,6 +32190,7 @@
"backendUserAssignedIdentity",
"existingAiFoundryAiServicesProject",
"logAnalyticsWorkspace",
"searchService",
"userAssignedIdentity",
"virtualNetwork"
]
Expand Down Expand Up @@ -32207,10 +32218,10 @@
"value": "[variables('aiSearchName')]"
},
"aiSearchResourceId": {
"value": "[reference('searchSearchServices').outputs.resourceId.value]"
"value": "[resourceId('Microsoft.Search/searchServices', variables('aiSearchName'))]"
},
"aiSearchLocation": {
"value": "[reference('searchSearchServices').outputs.location.value]"
"value": "[reference('searchService', '2024-06-01-preview', 'full').location]"
},
"aiSearchConnectionName": {
"value": "[variables('aiSearchName')]"
Expand Down Expand Up @@ -32285,7 +32296,7 @@
}
},
"dependsOn": [
"searchSearchServices"
"searchService"
]
},
"searchServiceToExistingAiServicesRoleAssignment": {
Expand All @@ -32302,7 +32313,7 @@
"mode": "Incremental",
"parameters": {
"principalId": {
"value": "[reference('searchSearchServices').outputs.systemAssignedMIPrincipalId.value]"
"value": "[reference('searchServiceUpdate').outputs.systemAssignedMIPrincipalId.value]"
},
"roleDefinitionId": {
"value": "5e0bd9bd-7b93-4f28-af87-19fc36ad61bd"
Expand Down Expand Up @@ -32363,7 +32374,7 @@
},
"dependsOn": [
"aiFoundryAiServices",
"searchSearchServices"
"searchServiceUpdate"
]
},
"storageAccount": {
Expand Down Expand Up @@ -40353,8 +40364,8 @@
},
"dependsOn": [
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageQueue)]",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageDfs)]",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageFile)]",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageDfs)]",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageBlob)]",
"userAssignedIdentity",
"virtualNetwork"
Expand Down