@@ -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
@@ -137,6 +163,7 @@ module azureAifoundry 'deploy_ai_foundry.bicep' = {
137163 params : {
138164 solutionName : ResourcePrefix
139165 solutionLocation : AzureAiServiceLocation
166+ aiFoundryName : aiFoundryName
140167 keyVaultName : kvault .outputs .keyvaultName
141168 gptModelName : llmModel
142169 gptModelVersion : gptModelVersion
@@ -145,6 +172,7 @@ module azureAifoundry 'deploy_ai_foundry.bicep' = {
145172 aiServicesKey : azureAiServices .listKeys ().key1
146173 aiServicesId : azureAiServices .id
147174 existingLogAnalyticsWorkspaceId : existingLogAnalyticsWorkspaceId
175+ aureaiFoundryEndpoint : aiFoundryProject .properties .endpoints ['AI Foundry API' ]
148176 }
149177 scope : resourceGroup (resourceGroup ().name )
150178}
@@ -323,7 +351,7 @@ resource containerAppBackend 'Microsoft.App/containerApps@2023-05-01' = {
323351 }
324352 {
325353 name : 'AZURE_OPENAI_ENDPOINT'
326- value : 'https://${azureAifoundry . outputs . aiServicesName }.openai.azure.com/'
354+ value : 'https://${aiFoundryName }.openai.azure.com/'
327355 }
328356 {
329357 name : 'MIGRATOR_AGENT_MODEL_DEPLOY'
@@ -359,7 +387,7 @@ resource containerAppBackend 'Microsoft.App/containerApps@2023-05-01' = {
359387 }
360388 {
361389 name : 'AZURE_AI_AGENT_PROJECT_NAME'
362- value : azureAifoundry . outputs . aiProjectName
390+ value : aiProjectName
363391 }
364392 {
365393 name : 'AZURE_AI_AGENT_RESOURCE_GROUP_NAME'
@@ -370,8 +398,8 @@ resource containerAppBackend 'Microsoft.App/containerApps@2023-05-01' = {
370398 value : subscription ().subscriptionId
371399 }
372400 {
373- name : 'AZURE_AI_AGENT_PROJECT_CONNECTION_STRING '
374- value : azureAifoundry . outputs . projectConnectionString
401+ name : 'AI_PROJECT_ENDPOINT '
402+ value : aiFoundryProject . properties . endpoints [ 'AI Foundry API' ]
375403 }
376404 ]
377405 resources : {
@@ -440,6 +468,7 @@ resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
440468 properties : {
441469 roleDefinitionId : subscriptionResourceId ('Microsoft.Authorization/roleDefinitions' , 'ba92f5b4-2d11-453d-a403-e96b0029c9fe' ) // Storage Blob Data Contributor
442470 principalId : containerAppBackend .identity .principalId
471+ principalType : 'ServicePrincipal'
443472 }
444473}
445474var openAiContributorRoleId = 'a001fd3d-188f-4b5d-821b-7da978bf7442' // Fixed Role ID for OpenAI Contributor
@@ -450,6 +479,7 @@ resource openAiRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-0
450479 properties : {
451480 roleDefinitionId : subscriptionResourceId ('Microsoft.Authorization/roleDefinitions' , openAiContributorRoleId ) // OpenAI Service Contributor
452481 principalId : containerAppBackend .identity .principalId
482+ principalType : 'ServicePrincipal'
453483 }
454484}
455485
@@ -466,20 +496,42 @@ resource containers 'Microsoft.Storage/storageAccounts/blobServices/containers@2
466496 dependsOn : [azureAifoundry ]
467497}]
468498
469- resource aiHubProject 'Microsoft.MachineLearningServices/workspaces@2024-01-01-preview' existing = {
470- name : '${abbrs .ai .aiHubProject }${ResourcePrefix }' // aiProjectName must be calculated - available at main start.
471- }
472-
473499resource aiDeveloper 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
474500 name : '64702f94-c441-49e6-a78b-ef80e0188fee'
475501}
476502
477503resource aiDeveloperAccessProj 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
478- name : guid (containerAppBackend .name , aiHubProject . id , aiDeveloper .id )
479- scope : aiHubProject
504+ name : guid (containerAppBackend .name , aiDeveloper .id )
505+ scope : resourceGroup ()
480506 properties : {
481507 roleDefinitionId : aiDeveloper .id
482508 principalId : containerAppBackend .identity .principalId
509+ principalType : 'ServicePrincipal'
510+ }
511+ }
512+
513+
514+ resource aiUser 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
515+ name : '53ca6127-db72-4b80-b1b0-d745d6d5456d'
516+ }
517+
518+ resource aiUserAccessProj 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
519+ name : guid (containerAppBackend .name , aiUser .id )
520+ scope : resourceGroup ()
521+ properties : {
522+ roleDefinitionId : aiUser .id
523+ principalId : containerAppBackend .identity .principalId
524+ principalType : 'ServicePrincipal'
525+ }
526+ }
527+
528+ resource aiUserAccessFoundry 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
529+ name : guid (containerAppBackend .name , aiFoundryProject .id )
530+ scope : resourceGroup ()
531+ properties : {
532+ roleDefinitionId : aiUser .id
533+ principalId : containerAppBackend .identity .principalId
534+ principalType : 'ServicePrincipal'
483535 }
484536}
485537
@@ -508,3 +560,7 @@ module deploymentScriptCLI 'br/public:avm/res/resources/deployment-script:0.5.1'
508560}
509561
510562output AZURE_AIFOUNDRY_NAME string = azureAiServices .name
563+
564+ output aiFoundryName string = aiFoundryName
565+ output aiProjectName string = aiFoundryProject .name
566+ output projectEndpointString string = aiFoundryProject .properties .endpoints ['AI Foundry API' ]
0 commit comments