Skip to content

Commit f584927

Browse files
committed
2 parents b6cb7d2 + 0c91d01 commit f584927

6 files changed

Lines changed: 733 additions & 344 deletions

File tree

infra/main.bicep

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,17 +1967,15 @@ module searchServiceIdentity 'br/public:avm/res/search/search-service:0.11.1' =
19671967
// ========== Search Service MI → AI Services Role Assignment ========== //
19681968
// The Search service system MI needs Cognitive Services OpenAI User on the AI Services account
19691969
// so that Knowledge Base MCP tools can call the model for semantic retrieval.
1970-
resource aiServicesForSearchRole 'Microsoft.CognitiveServices/accounts@2025-06-01' existing = {
1971-
name: aiFoundryAiServicesResourceName
1972-
}
1973-
1974-
resource searchServiceOpenAIRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
1975-
name: guid(aiServicesForSearchRole.id, searchServiceName, '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd')
1976-
scope: aiServicesForSearchRole
1977-
properties: {
1978-
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd') // Cognitive Services OpenAI User
1979-
principalId: searchServiceIdentity.outputs.systemAssignedMIPrincipalId!
1980-
principalType: 'ServicePrincipal'
1970+
// Deployed via a module scoped to the AI Services account's resource group so it works
1971+
// for both new and existing (cross-RG / cross-subscription) Foundry deployments.
1972+
module searchServiceOpenAIRole 'modules/search-openai-role.bicep' = {
1973+
name: take('module.search-openai-role.${solutionSuffix}', 64)
1974+
scope: resourceGroup(aiFoundryAiServicesSubscriptionId, aiFoundryAiServicesResourceGroupName)
1975+
params: {
1976+
aiFoundryAccountName: aiFoundryAiServicesResourceName
1977+
searchServicePrincipalId: searchServiceIdentity.outputs.systemAssignedMIPrincipalId!
1978+
roleNameGuidSeed: searchServiceName
19811979
}
19821980
}
19831981

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// ========================================================================
2+
// Assigns "Cognitive Services OpenAI User" on an AI Services (Cognitive
3+
// Services) account to the Search service's system-assigned managed identity.
4+
// Deployed at the scope of the AI Services account's resource group so it
5+
// works for both new and existing (cross-RG / cross-subscription) Foundry.
6+
// ========================================================================
7+
8+
param aiFoundryAccountName string
9+
param searchServicePrincipalId string
10+
param roleNameGuidSeed string
11+
12+
resource aiServicesAccount 'Microsoft.CognitiveServices/accounts@2025-06-01' existing = {
13+
name: aiFoundryAccountName
14+
}
15+
16+
resource searchServiceOpenAIRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
17+
name: guid(aiServicesAccount.id, roleNameGuidSeed, '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd')
18+
scope: aiServicesAccount
19+
properties: {
20+
roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd') // Cognitive Services OpenAI User
21+
principalId: searchServicePrincipalId
22+
principalType: 'ServicePrincipal'
23+
}
24+
}

0 commit comments

Comments
 (0)