Skip to content

Commit 92e2bcd

Browse files
author
Seth
committed
Search - fixed bug where roleassignments was not being used
1 parent 0a22b20 commit 92e2bcd

3 files changed

Lines changed: 52 additions & 68 deletions

File tree

infra/main.bicep

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,17 @@ module aiSearch 'modules/aisearch.bicep' = if (searchEnabled) {
258258
virtualNetworkResourceId: networkIsolation ? network.outputs.virtualNetworkId : ''
259259
virtualNetworkSubnetResourceId: networkIsolation ? network.outputs.vmSubnetId : ''
260260
logAnalyticsWorkspaceResourceId: logAnalyticsWorkspace.outputs.resourceId
261-
userObjectId: userObjectId
262261
roleAssignments: union(empty(userObjectId) ? [] : [
263262
{
264263
principalId: userObjectId
265264
principalType: 'User'
266265
roleDefinitionIdOrName: 'Search Index Data Contributor'
267266
}
267+
{
268+
principalId: userObjectId
269+
principalType: 'User'
270+
roleDefinitionIdOrName: 'Search Index Data Reader'
271+
}
268272
], [
269273
{
270274
principalId: cognitiveServices.outputs.aiServicesSystemAssignedMIPrincipalId

infra/main.json

Lines changed: 42 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"metadata": {
66
"_generator": {
77
"name": "bicep",
8-
"version": "0.36.1.42791",
9-
"templateHash": "14037525013444695971"
8+
"version": "0.33.93.31351",
9+
"templateHash": "5303146368545342618"
1010
}
1111
},
1212
"definitions": {
@@ -4900,8 +4900,8 @@
49004900
"metadata": {
49014901
"_generator": {
49024902
"name": "bicep",
4903-
"version": "0.36.1.42791",
4904-
"templateHash": "14424734402412352330"
4903+
"version": "0.33.93.31351",
4904+
"templateHash": "10563293765969438544"
49054905
}
49064906
},
49074907
"parameters": {
@@ -5580,8 +5580,8 @@
55805580
"metadata": {
55815581
"_generator": {
55825582
"name": "bicep",
5583-
"version": "0.36.1.42791",
5584-
"templateHash": "11746621349310683559"
5583+
"version": "0.33.93.31351",
5584+
"templateHash": "9442281453257963936"
55855585
}
55865586
},
55875587
"parameters": {
@@ -11965,8 +11965,8 @@
1196511965
"metadata": {
1196611966
"_generator": {
1196711967
"name": "bicep",
11968-
"version": "0.36.1.42791",
11969-
"templateHash": "2158520837294746606"
11968+
"version": "0.33.93.31351",
11969+
"templateHash": "12630130910180117756"
1197011970
}
1197111971
},
1197211972
"parameters": {
@@ -18193,8 +18193,8 @@
1819318193
"metadata": {
1819418194
"_generator": {
1819518195
"name": "bicep",
18196-
"version": "0.36.1.42791",
18197-
"templateHash": "8737464205872383016"
18196+
"version": "0.33.93.31351",
18197+
"templateHash": "5079190893808934258"
1819818198
}
1819918199
},
1820018200
"definitions": {
@@ -30221,8 +30221,8 @@
3022130221
"metadata": {
3022230222
"_generator": {
3022330223
"name": "bicep",
30224-
"version": "0.36.1.42791",
30225-
"templateHash": "532244891627057375"
30224+
"version": "0.33.93.31351",
30225+
"templateHash": "12413221929297508620"
3022630226
}
3022730227
},
3022830228
"definitions": {
@@ -36573,8 +36573,8 @@
3657336573
"metadata": {
3657436574
"_generator": {
3657536575
"name": "bicep",
36576-
"version": "0.36.1.42791",
36577-
"templateHash": "2348080591288311162"
36576+
"version": "0.33.93.31351",
36577+
"templateHash": "6894574649925342276"
3657836578
}
3657936579
},
3658036580
"definitions": {
@@ -39314,8 +39314,8 @@
3931439314
"metadata": {
3931539315
"_generator": {
3931639316
"name": "bicep",
39317-
"version": "0.36.1.42791",
39318-
"templateHash": "2348080591288311162"
39317+
"version": "0.33.93.31351",
39318+
"templateHash": "6894574649925342276"
3931939319
}
3932039320
},
3932139321
"definitions": {
@@ -42057,8 +42057,8 @@
4205742057
"metadata": {
4205842058
"_generator": {
4205942059
"name": "bicep",
42060-
"version": "0.36.1.42791",
42061-
"templateHash": "2348080591288311162"
42060+
"version": "0.33.93.31351",
42061+
"templateHash": "6894574649925342276"
4206242062
}
4206342063
},
4206442064
"definitions": {
@@ -44800,8 +44800,8 @@
4480044800
"metadata": {
4480144801
"_generator": {
4480244802
"name": "bicep",
44803-
"version": "0.36.1.42791",
44804-
"templateHash": "2348080591288311162"
44803+
"version": "0.33.93.31351",
44804+
"templateHash": "6894574649925342276"
4480544805
}
4480644806
},
4480744807
"definitions": {
@@ -47540,8 +47540,8 @@
4754047540
"metadata": {
4754147541
"_generator": {
4754247542
"name": "bicep",
47543-
"version": "0.36.1.42791",
47544-
"templateHash": "2348080591288311162"
47543+
"version": "0.33.93.31351",
47544+
"templateHash": "6894574649925342276"
4754547545
}
4754647546
},
4754747547
"definitions": {
@@ -50283,8 +50283,8 @@
5028350283
"metadata": {
5028450284
"_generator": {
5028550285
"name": "bicep",
50286-
"version": "0.36.1.42791",
50287-
"templateHash": "2348080591288311162"
50286+
"version": "0.33.93.31351",
50287+
"templateHash": "6894574649925342276"
5028850288
}
5028950289
},
5029050290
"definitions": {
@@ -53023,8 +53023,8 @@
5302353023
"metadata": {
5302453024
"_generator": {
5302553025
"name": "bicep",
53026-
"version": "0.36.1.42791",
53027-
"templateHash": "2348080591288311162"
53026+
"version": "0.33.93.31351",
53027+
"templateHash": "6894574649925342276"
5302853028
}
5302953029
},
5303053030
"definitions": {
@@ -55788,8 +55788,8 @@
5578855788
"metadata": {
5578955789
"_generator": {
5579055790
"name": "bicep",
55791-
"version": "0.36.1.42791",
55792-
"templateHash": "15578119539506362308"
55791+
"version": "0.33.93.31351",
55792+
"templateHash": "337781424599225735"
5579355793
}
5579455794
},
5579555795
"parameters": {
@@ -55977,11 +55977,8 @@
5597755977
"logAnalyticsWorkspaceResourceId": {
5597855978
"value": "[reference('logAnalyticsWorkspace').outputs.resourceId.value]"
5597955979
},
55980-
"userObjectId": {
55981-
"value": "[parameters('userObjectId')]"
55982-
},
5598355980
"roleAssignments": {
55984-
"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')))]"
55981+
"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')))]"
5598555982
},
5598655983
"tags": {
5598755984
"value": "[variables('allTags')]"
@@ -55994,8 +55991,8 @@
5599455991
"metadata": {
5599555992
"_generator": {
5599655993
"name": "bicep",
55997-
"version": "0.36.1.42791",
55998-
"templateHash": "10624928188153796868"
55994+
"version": "0.33.93.31351",
55995+
"templateHash": "9060803724389588162"
5599955996
}
5600055997
},
5600155998
"definitions": {
@@ -56120,12 +56117,6 @@
5612056117
"description": "Specifies whether network isolation is enabled. This will create a private endpoint for the AI Search resource and link the private DNS zone."
5612156118
}
5612256119
},
56123-
"userObjectId": {
56124-
"type": "string",
56125-
"metadata": {
56126-
"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."
56127-
}
56128-
},
5612956120
"roleAssignments": {
5613056121
"type": "array",
5613156122
"items": {
@@ -59221,7 +59212,9 @@
5922159212
"replicaCount": {
5922259213
"value": 3
5922359214
},
59224-
"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'))))]",
59215+
"roleAssignments": {
59216+
"value": "[parameters('roleAssignments')]"
59217+
},
5922559218
"diagnosticSettings": {
5922659219
"value": [
5922759220
{
@@ -61416,8 +61409,8 @@
6141661409
"metadata": {
6141761410
"_generator": {
6141861411
"name": "bicep",
61419-
"version": "0.36.1.42791",
61420-
"templateHash": "14156198524686936179"
61412+
"version": "0.33.93.31351",
61413+
"templateHash": "10286244752482293080"
6142161414
}
6142261415
},
6142361416
"parameters": {
@@ -61985,8 +61978,8 @@
6198561978
"metadata": {
6198661979
"_generator": {
6198761980
"name": "bicep",
61988-
"version": "0.36.1.42791",
61989-
"templateHash": "9207373860269569676"
61981+
"version": "0.33.93.31351",
61982+
"templateHash": "13278853949319290770"
6199061983
}
6199161984
},
6199261985
"parameters": {
@@ -69918,8 +69911,8 @@
6991869911
"metadata": {
6991969912
"_generator": {
6992069913
"name": "bicep",
69921-
"version": "0.36.1.42791",
69922-
"templateHash": "7173901627480655800"
69914+
"version": "0.33.93.31351",
69915+
"templateHash": "1436217564672922666"
6992369916
}
6992469917
},
6992569918
"definitions": {
@@ -77117,8 +77110,8 @@
7711777110
"metadata": {
7711877111
"_generator": {
7711977112
"name": "bicep",
77120-
"version": "0.36.1.42791",
77121-
"templateHash": "18362011243916437863"
77113+
"version": "0.33.93.31351",
77114+
"templateHash": "5330058909966791926"
7712277115
}
7712377116
},
7712477117
"definitions": {

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

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

91-
import { roleAssignmentType } from 'br/public:avm/utl/types/avm-common-types:0.5.1'
78+
9279

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

0 commit comments

Comments
 (0)