@@ -57,9 +57,11 @@ var cosmosdbLogContainer = 'cmsalog'
5757var containerName = 'appstorage'
5858var storageSkuName = 'Standard_LRS'
5959var storageContainerName = replace (replace (replace (replace ('${ResourcePrefix }cast' , '-' , '' ), '_' , '' ), '.' , '' ),'/' , '' )
60- var azureAiServicesName = '${abbrs .ai .aiServices }${ResourcePrefix }'
61-
6260
61+ var aiFoundryName = '${abbrs .ai .aiFoundry }${ResourcePrefix }'
62+ var aiProjectDescription = 'AI foundary project for CPS template'
63+ var aiProjectName = '${abbrs .ai .aiFoundryProject }${ResourcePrefix }'
64+ var aiProjectFriendlyName = aiProjectName
6365
6466var aiModelDeployments = [
6567 {
@@ -74,15 +76,39 @@ var aiModelDeployments = [
7476 }
7577]
7678
77- resource azureAiServices 'Microsoft.CognitiveServices/accounts@2024 -04-01-preview' = {
78- name : azureAiServicesName
79+ resource azureAiServices 'Microsoft.CognitiveServices/accounts@2025 -04-01-preview' = {
80+ name : aiFoundryName
7981 location : AzureAiServiceLocation
8082 sku : {
8183 name : 'S0'
8284 }
8385 kind : 'AIServices'
86+ identity : {
87+ type : 'SystemAssigned'
88+ }
89+ properties : {
90+ allowProjectManagement : true
91+ customSubDomainName : aiFoundryName
92+ networkAcls : {
93+ defaultAction : 'Allow'
94+ virtualNetworkRules : []
95+ ipRules : []
96+ }
97+ publicNetworkAccess : 'Enabled'
98+ disableLocalAuth : false
99+ }
100+ }
101+
102+ resource aiFoundryProject 'Microsoft.CognitiveServices/accounts/projects@2025-04-01-preview' = {
103+ parent : azureAiServices
104+ name : aiProjectName
105+ location : AzureAiServiceLocation
106+ identity : {
107+ type : 'SystemAssigned'
108+ }
84109 properties : {
85- customSubDomainName : azureAiServicesName
110+ description : aiProjectDescription
111+ displayName : aiProjectFriendlyName
86112 }
87113}
88114
@@ -136,6 +162,7 @@ module azureAifoundry 'deploy_ai_foundry.bicep' = {
136162 params : {
137163 solutionName : ResourcePrefix
138164 solutionLocation : AzureAiServiceLocation
165+ aiFoundryName : aiFoundryName
139166 keyVaultName : kvault .outputs .keyvaultName
140167 gptModelName : llmModel
141168 gptModelVersion : gptModelVersion
@@ -144,6 +171,7 @@ module azureAifoundry 'deploy_ai_foundry.bicep' = {
144171 aiServicesKey : azureAiServices .listKeys ().key1
145172 aiServicesId : azureAiServices .id
146173 existingLogAnalyticsWorkspaceId : existingLogAnalyticsWorkspaceId
174+ aureaiFoundryEndpoint : aiFoundryProject .properties .endpoints ['AI Foundry API' ]
147175 }
148176 scope : resourceGroup (resourceGroup ().name )
149177}
@@ -322,7 +350,7 @@ resource containerAppBackend 'Microsoft.App/containerApps@2023-05-01' = {
322350 }
323351 {
324352 name : 'AZURE_OPENAI_ENDPOINT'
325- value : 'https://${azureAifoundry . outputs . aiServicesName }.openai.azure.com/'
353+ value : 'https://${aiFoundryName }.openai.azure.com/'
326354 }
327355 {
328356 name : 'MIGRATOR_AGENT_MODEL_DEPLOY'
@@ -358,7 +386,7 @@ resource containerAppBackend 'Microsoft.App/containerApps@2023-05-01' = {
358386 }
359387 {
360388 name : 'AZURE_AI_AGENT_PROJECT_NAME'
361- value : azureAifoundry . outputs . aiProjectName
389+ value : aiProjectName
362390 }
363391 {
364392 name : 'AZURE_AI_AGENT_RESOURCE_GROUP_NAME'
@@ -369,8 +397,8 @@ resource containerAppBackend 'Microsoft.App/containerApps@2023-05-01' = {
369397 value : subscription ().subscriptionId
370398 }
371399 {
372- name : 'AZURE_AI_AGENT_PROJECT_CONNECTION_STRING '
373- value : azureAifoundry . outputs . projectConnectionString
400+ name : 'AI_PROJECT_ENDPOINT '
401+ value : aiFoundryProject . properties . endpoints [ 'AI Foundry API' ]
374402 }
375403 ]
376404 resources : {
@@ -439,6 +467,7 @@ resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
439467 properties : {
440468 roleDefinitionId : subscriptionResourceId ('Microsoft.Authorization/roleDefinitions' , 'ba92f5b4-2d11-453d-a403-e96b0029c9fe' ) // Storage Blob Data Contributor
441469 principalId : containerAppBackend .identity .principalId
470+ principalType : 'ServicePrincipal'
442471 }
443472}
444473var openAiContributorRoleId = 'a001fd3d-188f-4b5d-821b-7da978bf7442' // Fixed Role ID for OpenAI Contributor
@@ -449,6 +478,7 @@ resource openAiRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-0
449478 properties : {
450479 roleDefinitionId : subscriptionResourceId ('Microsoft.Authorization/roleDefinitions' , openAiContributorRoleId ) // OpenAI Service Contributor
451480 principalId : containerAppBackend .identity .principalId
481+ principalType : 'ServicePrincipal'
452482 }
453483}
454484
@@ -465,20 +495,42 @@ resource containers 'Microsoft.Storage/storageAccounts/blobServices/containers@2
465495 dependsOn : [azureAifoundry ]
466496}]
467497
468- resource aiHubProject 'Microsoft.MachineLearningServices/workspaces@2024-01-01-preview' existing = {
469- name : '${abbrs .ai .aiHubProject }${ResourcePrefix }' // aiProjectName must be calculated - available at main start.
470- }
471-
472498resource aiDeveloper 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
473499 name : '64702f94-c441-49e6-a78b-ef80e0188fee'
474500}
475501
476502resource aiDeveloperAccessProj 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
477- name : guid (containerAppBackend .name , aiHubProject . id , aiDeveloper .id )
478- scope : aiHubProject
503+ name : guid (containerAppBackend .name , aiDeveloper .id )
504+ scope : resourceGroup ()
479505 properties : {
480506 roleDefinitionId : aiDeveloper .id
481507 principalId : containerAppBackend .identity .principalId
508+ principalType : 'ServicePrincipal'
509+ }
510+ }
511+
512+
513+ resource aiUser 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
514+ name : '53ca6127-db72-4b80-b1b0-d745d6d5456d'
515+ }
516+
517+ resource aiUserAccessProj 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
518+ name : guid (containerAppBackend .name , aiUser .id )
519+ scope : resourceGroup ()
520+ properties : {
521+ roleDefinitionId : aiUser .id
522+ principalId : containerAppBackend .identity .principalId
523+ principalType : 'ServicePrincipal'
524+ }
525+ }
526+
527+ resource aiUserAccessFoundry 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
528+ name : guid (containerAppBackend .name , aiFoundryProject .id )
529+ scope : resourceGroup ()
530+ properties : {
531+ roleDefinitionId : aiUser .id
532+ principalId : containerAppBackend .identity .principalId
533+ principalType : 'ServicePrincipal'
482534 }
483535}
484536
@@ -508,3 +560,6 @@ module deploymentScriptCLI 'br/public:avm/res/resources/deployment-script:0.5.1'
508560
509561output AZURE_AIFOUNDRY_NAME string = azureAiServices .name
510562output WEB_APP_URL string = 'https://${containerAppFrontend .outputs .fqdn }'
563+ output aiFoundryName string = aiFoundryName
564+ output aiProjectName string = aiFoundryProject .name
565+ output projectEndpointString string = aiFoundryProject .properties .endpoints ['AI Foundry API' ]
0 commit comments