Skip to content

Commit 260e54a

Browse files
Enable system assigned managed identity for existing Foundry project
1 parent aaf336a commit 260e54a

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

infra/modules/account/main.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ module existing_cognitive_service_dependencies './modules/dependencies.bicep' =
277277
projectName: projectName
278278
projectDescription: projectDescription
279279
azureExistingAIProjectResourceId: existingFoundryProjectResourceId
280-
location: location
280+
location: cognitiveServiceExisting.?location!
281281
deployments: deployments
282282
diagnosticSettings: diagnosticSettings
283283
lock: lock

infra/modules/account/modules/dependencies.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ param name string
2323
])
2424
param sku string = 'S0'
2525

26-
@description('Optional. Location for all Resources.')
27-
param location string = resourceGroup().location
26+
@description('Optional. Location for Cognitive Services.')
27+
param location string
2828

2929
@description('Optional. Tags of the resource.')
3030
param tags object?

infra/modules/account/modules/project.bicep

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
param name string
33

44
@description('Required. The location of the Project resource.')
5-
param location string = resourceGroup().location
5+
param location string
66

77
@description('Optional. The description of the AI Foundry project to create. Defaults to the project name.')
88
param desc string = name
@@ -19,7 +19,7 @@ param azureExistingAIProjectResourceId string = ''
1919
// // Extract components from existing AI Project Resource ID if provided
2020
var useExistingProject = !empty(azureExistingAIProjectResourceId)
2121
var existingProjName = useExistingProject ? last(split(azureExistingAIProjectResourceId, '/')) : ''
22-
var existingProjEndpoint = useExistingProject ? format('https://{0}.services.ai.azure.com/api/projects/{1}', aiServicesName, existingProjName) : ''
22+
// var existingProjEndpoint = useExistingProject ? format('https://{0}.services.ai.azure.com/api/projects/{1}', aiServicesName, existingProjName) : ''
2323

2424
// Reference to cognitive service in current resource group for new projects
2525
resource cogServiceReference 'Microsoft.CognitiveServices/accounts@2024-10-01' existing = {
@@ -41,11 +41,19 @@ resource aiProject 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-pre
4141
}
4242
}
4343

44+
// Assign identity to existing project
45+
resource existingProject 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-preview' = if (useExistingProject && !empty(existingProjName)) {
46+
name: existingProjName
47+
parent: cogServiceReference
48+
location: location
49+
identity: { type: 'SystemAssigned' }
50+
}
51+
4452
@description('AI Project metadata including name, resource ID, and API endpoint.')
4553
output aiProjectInfo aiProjectOutputType = {
46-
name: useExistingProject ? existingProjName : aiProject.name
47-
resourceId: useExistingProject ? azureExistingAIProjectResourceId : aiProject.id
48-
apiEndpoint: useExistingProject ? existingProjEndpoint : aiProject.properties.endpoints['AI Foundry API']
54+
name: useExistingProject ? existingProject.name : aiProject.name
55+
resourceId: useExistingProject ? existingProject.id : aiProject.id
56+
apiEndpoint: useExistingProject ? existingProject.properties.endpoints['AI Foundry API'] : aiProject.properties.endpoints['AI Foundry API']
4957
}
5058

5159
@export()

0 commit comments

Comments
 (0)