@@ -24,7 +24,6 @@ var keyvaultName = '${abbrs.security.keyVault}${solutionName}'
2424var location = solutionLocation //'eastus2'
2525var aiProjectName = '${abbrs .ai .aiFoundryProject }${solutionName }'
2626var aiSearchName = '${abbrs .ai .aiSearch }${solutionName }'
27- var aiSearchConnectionName = 'myVectorStoreProjectConnectionName-${solutionName }'
2827
2928var aiModelDeployments = [
3029 {
@@ -57,8 +56,8 @@ var existingOpenAIEndpoint = !empty(azureExistingAIProjectResourceId) ? format('
5756var existingProjEndpoint = !empty (azureExistingAIProjectResourceId ) ? format ('https://{0}.services.ai.azure.com/api/projects/{1}' , split (azureExistingAIProjectResourceId , '/' )[8 ], split (azureExistingAIProjectResourceId , '/' )[10 ]) : ''
5857var existingAIServicesName = !empty (azureExistingAIProjectResourceId ) ? split (azureExistingAIProjectResourceId , '/' )[8 ] : ''
5958var existingAIProjectName = !empty (azureExistingAIProjectResourceId ) ? split (azureExistingAIProjectResourceId , '/' )[10 ] : ''
60- var existingAIServiceSubscription = !empty (azureExistingAIProjectResourceId ) ? split (azureExistingAIProjectResourceId , '/' )[2 ] : subscription (). subscriptionId
61- var existingAIServiceResourceGroup = !empty (azureExistingAIProjectResourceId ) ? split (azureExistingAIProjectResourceId , '/' )[4 ] : resourceGroup (). name
59+ var existingAIServiceSubscription = !empty (azureExistingAIProjectResourceId ) ? split (azureExistingAIProjectResourceId , '/' )[2 ] : ''
60+ var existingAIServiceResourceGroup = !empty (azureExistingAIProjectResourceId ) ? split (azureExistingAIProjectResourceId , '/' )[4 ] : ''
6261
6362resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = {
6463 name : keyVaultName
@@ -162,9 +161,6 @@ resource aiSearch 'Microsoft.Search/searchServices@2024-06-01-preview' = {
162161 sku : {
163162 name : 'basic'
164163 }
165- identity : {
166- type : 'SystemAssigned'
167- }
168164 properties : {
169165 replicaCount : 1
170166 partitionCount : 1
@@ -176,7 +172,10 @@ resource aiSearch 'Microsoft.Search/searchServices@2024-06-01-preview' = {
176172 encryptionWithCmk : {
177173 enforcement : 'Unspecified'
178174 }
179- disableLocalAuth : true
175+ disableLocalAuth : false
176+ authOptions : {
177+ apiKeyOnly : {}
178+ }
180179 semanticSearch : 'free'
181180 }
182181}
@@ -193,7 +192,7 @@ resource aiProject 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-pre
193192}
194193
195194resource aiproject_aisearch_connection_new 'Microsoft.CognitiveServices/accounts/projects/connections@2025-04-01-preview' = if (empty (azureExistingAIProjectResourceId )) {
196- name : aiSearchConnectionName
195+ name : 'myVectorStoreProjectConnectionName-${ solutionName }'
197196 parent : aiProject
198197 properties : {
199198 category : 'CognitiveSearch'
@@ -217,121 +216,31 @@ module existing_AIProject_SearchConnectionModule 'deploy_aifp_aisearch_connectio
217216 aiSearchName : aiSearchName
218217 aiSearchResourceId : aiSearch .id
219218 aiSearchLocation : aiSearch .location
220- aiSearchConnectionName : aiSearchConnectionName
219+ solutionName : solutionName
221220 }
222221}
223222
224223resource aiUser 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
225224 name : '53ca6127-db72-4b80-b1b0-d745d6d5456d'
226225}
227226
228- resource assignFoundryRoleToMI 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (empty (azureExistingAIProjectResourceId )) {
229- name : guid (resourceGroup ().id , aiServices .id , aiUser .id )
230- scope : aiServices
227+ resource aiUserAccessFoundry 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
228+ name : guid (resourceGroup ().id , managedIdentityObjectId , aiUser .id )
231229 properties : {
232230 principalId : managedIdentityObjectId
233231 roleDefinitionId : aiUser .id
234- principalType : 'ServicePrincipal'
232+ principalType : 'ServicePrincipal'
235233 }
236234}
237235
238- module assignFoundryRoleToMIExisting 'deploy_foundry_role_assignment.bicep' = if (!empty (azureExistingAIProjectResourceId )) {
239- name : 'assignFoundryRoleToMI '
236+ module assignAiUserRoleToManagedIdentity 'deploy_foundry_role_assignment.bicep' = if (!empty (azureExistingAIProjectResourceId )) {
237+ name : 'assignAiUserRoleToManagedIdentity '
240238 scope : resourceGroup (existingAIServiceSubscription , existingAIServiceResourceGroup )
241239 params : {
242240 roleDefinitionId : aiUser .id
243- roleAssignmentName : guid (resourceGroup ().id , managedIdentityObjectId , aiUser .id , 'foundry' )
244- aiServicesName : !empty (azureExistingAIProjectResourceId ) ? existingAIServicesName : aiServicesName
245- aiProjectName : !empty (azureExistingAIProjectResourceId ) ? existingAIProjectName : aiProjectName
246- principalId : managedIdentityObjectId
247- }
248- }
249-
250- resource assignAiUserToAiFoundryCU 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
251- name : guid (resourceGroup ().id , aiServices_CU .id , aiUser .id )
252- scope : aiServices_CU
253- properties : {
254- principalId : managedIdentityObjectId
255- roleDefinitionId : aiUser .id
256- principalType : 'ServicePrincipal'
257- }
258- }
259-
260- resource cognitiveServicesOpenAIUser 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
261- name : '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
262- }
263-
264- module assignOpenAIRoleToAISearch 'deploy_foundry_role_assignment.bicep' = {
265- name : 'assignOpenAIRoleToAISearch'
266- scope : resourceGroup (existingAIServiceSubscription , existingAIServiceResourceGroup )
267- params : {
268- roleDefinitionId : cognitiveServicesOpenAIUser .id
269- roleAssignmentName : guid (resourceGroup ().id , aiSearch .id , cognitiveServicesOpenAIUser .id , 'openai-foundry' )
241+ roleAssignmentName : guid (managedIdentityObjectId , aiServices .id , aiUser .id )
270242 aiServicesName : !empty (azureExistingAIProjectResourceId ) ? existingAIServicesName : aiServicesName
271- aiProjectName : !empty (azureExistingAIProjectResourceId ) ? existingAIProjectName : aiProjectName
272- principalId : aiSearch .identity .principalId
273- }
274- }
275-
276- resource searchIndexDataReader 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
277- name : '1407120a-92aa-4202-b7e9-c0e197c71c8f'
278- }
279-
280- resource assignSearchIndexDataReaderToAiProject 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (empty (azureExistingAIProjectResourceId )) {
281- name : guid (resourceGroup ().id , aiProject .id , searchIndexDataReader .id )
282- scope : aiSearch
283- properties : {
284- principalId : aiProject .identity .principalId
285- roleDefinitionId : searchIndexDataReader .id
286- principalType : 'ServicePrincipal'
287- }
288- }
289-
290- resource assignSearchIndexDataReaderToExistingAiProject 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (!empty (azureExistingAIProjectResourceId )) {
291- name : guid (resourceGroup ().id , existingAIProjectName , searchIndexDataReader .id , 'Existing' )
292- scope : aiSearch
293- properties : {
294- principalId : assignOpenAIRoleToAISearch .outputs .aiProjectPrincipalId
295- roleDefinitionId : searchIndexDataReader .id
296- principalType : 'ServicePrincipal'
297- }
298- }
299-
300- resource searchServiceContributor 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
301- name : '7ca78c08-252a-4471-8644-bb5ff32d4ba0'
302- }
303-
304- resource assignSearchServiceContributorToAiProject 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (empty (azureExistingAIProjectResourceId )) {
305- name : guid (resourceGroup ().id , aiProject .id , searchServiceContributor .id )
306- scope : aiSearch
307- properties : {
308- principalId : aiProject .identity .principalId
309- roleDefinitionId : searchServiceContributor .id
310- principalType : 'ServicePrincipal'
311- }
312- }
313-
314- resource assignSearchServiceContributorToExistingAiProject 'Microsoft.Authorization/roleAssignments@2022-04-01' = if (!empty (azureExistingAIProjectResourceId )) {
315- name : guid (resourceGroup ().id , existingAIProjectName , searchServiceContributor .id , 'Existing' )
316- scope : aiSearch
317- properties : {
318- principalId : assignOpenAIRoleToAISearch .outputs .aiProjectPrincipalId
319- roleDefinitionId : searchServiceContributor .id
320- principalType : 'ServicePrincipal'
321- }
322- }
323-
324- resource searchIndexDataContributor 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
325- name : '8ebe5a00-799e-43f5-93ac-243d3dce84a7'
326- }
327-
328- resource assignSearchIndexDataContributorToMI 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
329- name : guid (resourceGroup ().id , aiProject .id , searchIndexDataContributor .id )
330- scope : aiSearch
331- properties : {
332- principalId : managedIdentityObjectId
333- roleDefinitionId : searchIndexDataContributor .id
334- principalType : 'ServicePrincipal'
243+ userassignedIdentityId : managedIdentityObjectId
335244 }
336245}
337246
@@ -383,14 +292,6 @@ resource azureOpenAIEndpointEntry 'Microsoft.KeyVault/vaults/secrets@2021-11-01-
383292 }
384293}
385294
386- resource azureOpenAIEmbeddingDeploymentModel 'Microsoft.KeyVault/vaults/secrets@2021-11-01-preview' = {
387- parent : keyVault
388- name : 'AZURE-OPENAI-EMBEDDING-MODEL'
389- properties : {
390- value : embeddingModel
391- }
392- }
393-
394295resource azureOpenAICUEndpointEntry 'Microsoft.KeyVault/vaults/secrets@2021-11-01-preview' = {
395296 parent : keyVault
396297 name : 'AZURE-OPENAI-CU-ENDPOINT'
@@ -407,6 +308,14 @@ resource azureOpenAICUApiVersionEntry 'Microsoft.KeyVault/vaults/secrets@2021-11
407308 }
408309}
409310
311+ resource azureSearchAdminKeyEntry 'Microsoft.KeyVault/vaults/secrets@2021-11-01-preview' = {
312+ parent : keyVault
313+ name : 'AZURE-SEARCH-KEY'
314+ properties : {
315+ value : aiSearch .listAdminKeys ().primaryKey
316+ }
317+ }
318+
410319resource azureSearchServiceEndpointEntry 'Microsoft.KeyVault/vaults/secrets@2021-11-01-preview' = {
411320 parent : keyVault
412321 name : 'AZURE-SEARCH-ENDPOINT'
@@ -481,7 +390,6 @@ output aiSearchId string = aiSearch.id
481390output aiSearchTarget string = 'https://${aiSearch .name }.search.windows.net'
482391output aiSearchService string = aiSearch .name
483392output aiProjectName string = !empty (existingAIProjectName ) ? existingAIProjectName : aiProject .name
484- output aiSearchConnectionName string = aiSearchConnectionName
485393
486394output applicationInsightsId string = applicationInsights .id
487395output logAnalyticsWorkspaceResourceName string = useExisting ? existingLogAnalyticsWorkspace .name : logAnalytics .name
0 commit comments