Skip to content

Commit be3f3cb

Browse files
Merge pull request #60 from microsoft/fix/ai-search-role-assign
Search - fix role assignments
2 parents 513526c + 48d1531 commit be3f3cb

3 files changed

Lines changed: 16 additions & 32 deletions

File tree

infra/main.bicep

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,17 @@ module aiSearch 'modules/aisearch.bicep' = if (searchEnabled) {
281281
virtualNetworkResourceId: networkIsolation ? network.outputs.virtualNetworkId : ''
282282
virtualNetworkSubnetResourceId: networkIsolation ? network.outputs.vmSubnetId : ''
283283
logAnalyticsWorkspaceResourceId: logAnalyticsWorkspace.outputs.resourceId
284-
userObjectId: userObjectId
285284
roleAssignments: union(empty(userObjectId) ? [] : [
286285
{
287286
principalId: userObjectId
288287
principalType: 'User'
289288
roleDefinitionIdOrName: 'Search Index Data Contributor'
290289
}
290+
{
291+
principalId: userObjectId
292+
principalType: 'User'
293+
roleDefinitionIdOrName: 'Search Index Data Reader'
294+
}
291295
], [
292296
{
293297
principalId: cognitiveServices.outputs.aiServicesSystemAssignedMIPrincipalId

infra/main.json

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "0.36.1.42791",
9-
"templateHash": "1266095135796943159"
9+
"templateHash": "4273186265838174664"
1010
}
1111
},
1212
"definitions": {
@@ -55937,11 +55937,8 @@
5593755937
"logAnalyticsWorkspaceResourceId": {
5593855938
"value": "[reference('logAnalyticsWorkspace').outputs.resourceId.value]"
5593955939
},
55940-
"userObjectId": {
55941-
"value": "[parameters('userObjectId')]"
55942-
},
5594355940
"roleAssignments": {
55944-
"value": "[union(if(empty(parameters('userObjectId')), createArray(), createArray(createObject('principalId', parameters('userObjectId'), 'principalType', 'User', 'roleDefinitionIdOrName', 'Search Index Data Contributor'))), createArray(createObject('principalId', reference('cognitiveServices').outputs.aiServicesSystemAssignedMIPrincipalId.value, 'principalType', 'ServicePrincipal', 'roleDefinitionIdOrName', 'Search Index Data Contributor'), createObject('principalId', reference('cognitiveServices').outputs.aiServicesSystemAssignedMIPrincipalId.value, 'principalType', 'ServicePrincipal', 'roleDefinitionIdOrName', 'Search Service Contributor')))]"
55941+
"value": "[union(if(empty(parameters('userObjectId')), createArray(), createArray(createObject('principalId', parameters('userObjectId'), 'principalType', 'User', 'roleDefinitionIdOrName', 'Search Index Data Contributor'), createObject('principalId', parameters('userObjectId'), 'principalType', 'User', 'roleDefinitionIdOrName', 'Search Index Data Reader'))), createArray(createObject('principalId', reference('cognitiveServices').outputs.aiServicesSystemAssignedMIPrincipalId.value, 'principalType', 'ServicePrincipal', 'roleDefinitionIdOrName', 'Search Index Data Contributor'), createObject('principalId', reference('cognitiveServices').outputs.aiServicesSystemAssignedMIPrincipalId.value, 'principalType', 'ServicePrincipal', 'roleDefinitionIdOrName', 'Search Service Contributor')))]"
5594555942
},
5594655943
"tags": {
5594755944
"value": "[variables('allTags')]"
@@ -55955,7 +55952,7 @@
5595555952
"_generator": {
5595655953
"name": "bicep",
5595755954
"version": "0.36.1.42791",
55958-
"templateHash": "10624928188153796868"
55955+
"templateHash": "7886886176219744151"
5595955956
}
5596055957
},
5596155958
"definitions": {
@@ -56080,12 +56077,6 @@
5608056077
"description": "Specifies whether network isolation is enabled. This will create a private endpoint for the AI Search resource and link the private DNS zone."
5608156078
}
5608256079
},
56083-
"userObjectId": {
56084-
"type": "string",
56085-
"metadata": {
56086-
"description": "Specifies the object id of a Microsoft Entra ID user. In general, this the object id of the system administrator who deploys the Azure resources. This defaults to the deploying user."
56087-
}
56088-
},
5608956080
"roleAssignments": {
5609056081
"type": "array",
5609156082
"items": {
@@ -59181,7 +59172,9 @@
5918159172
"replicaCount": {
5918259173
"value": 3
5918359174
},
59184-
"roleAssignments": "[if(empty(parameters('userObjectId')), createObject('value', createArray()), createObject('value', createArray(createObject('principalId', parameters('userObjectId'), 'principalType', 'User', 'roleDefinitionIdOrName', 'Search Index Data Contributor'), createObject('principalId', parameters('userObjectId'), 'principalType', 'User', 'roleDefinitionIdOrName', 'Search Index Data Reader'))))]",
59175+
"roleAssignments": {
59176+
"value": "[parameters('roleAssignments')]"
59177+
},
5918559178
"diagnosticSettings": {
5918659179
"value": [
5918759180
{

infra/modules/aisearch.bicep

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ param logAnalyticsWorkspaceResourceId string
1919
@description('Specifies whether network isolation is enabled. This will create a private endpoint for the AI Search resource and link the private DNS zone.')
2020
param networkIsolation bool = true
2121

22-
@description('Specifies the object id of a Microsoft Entra ID user. In general, this the object id of the system administrator who deploys the Azure resources. This defaults to the deploying user.')
23-
param userObjectId string
24-
22+
import { roleAssignmentType } from 'br/public:avm/utl/types/avm-common-types:0.5.1'
2523
@description('Optional. Array of role assignments to create.')
2624
param roleAssignments roleAssignmentType[]?
2725

@@ -54,20 +52,9 @@ module aiSearch 'br/public:avm/res/search/search-service:0.9.2' = {
5452
publicNetworkAccess: networkIsolation ? 'Disabled' : 'Enabled'
5553
disableLocalAuth: true
5654
sku: 'standard'
57-
partitionCount:1
58-
replicaCount:3
59-
roleAssignments: empty(userObjectId) ? [] : [
60-
{
61-
principalId: userObjectId
62-
principalType: 'User'
63-
roleDefinitionIdOrName: 'Search Index Data Contributor'
64-
}
65-
{
66-
principalId: userObjectId
67-
principalType: 'User'
68-
roleDefinitionIdOrName: 'Search Index Data Reader'
69-
}
70-
]
55+
partitionCount: 1
56+
replicaCount: 3
57+
roleAssignments: roleAssignments
7158
diagnosticSettings: [
7259
{
7360
workspaceResourceId: logAnalyticsWorkspaceResourceId
@@ -89,7 +76,7 @@ module aiSearch 'br/public:avm/res/search/search-service:0.9.2' = {
8976
}
9077
}
9178

92-
import { roleAssignmentType } from 'br/public:avm/utl/types/avm-common-types:0.5.1'
79+
9380

9481
output resourceId string = aiSearch.outputs.resourceId
9582
output name string = aiSearch.outputs.name

0 commit comments

Comments
 (0)