@@ -293,7 +293,7 @@ module applicationInsights 'br/public:avm/res/insights/component:0.6.0' = if (ap
293293// WAF best practices for identity and access management: https://learn.microsoft.com/en-us/azure/well-architected/security/identity-access
294294var userAssignedManagedIdentityEnabled = userAssignedManagedIdentityConfiguration .?enabled ?? true
295295var userAssignedManagedIdentityResourceName = userAssignedManagedIdentityConfiguration .?name ?? 'id-${solutionPrefix }'
296- module userAssignedIdentity 'br/public:avm/res/managed-identity/user-assigned-identity:0.4.1' = if (userAssignedManagedIdentityEnabled ) {
296+ module userAssignedIdentityAIHub 'br/public:avm/res/managed-identity/user-assigned-identity:0.4.1' = if (userAssignedManagedIdentityEnabled ) {
297297 name : take ('avm.res.managed-identity.user-assigned-identity.${userAssignedManagedIdentityResourceName }' , 64 )
298298 params : {
299299 name : userAssignedManagedIdentityResourceName
@@ -753,7 +753,7 @@ module aiFoundryAiServices 'modules/ai-services.bicep' = if (aiFoundryAIservices
753753 diagnosticSettings : [{ workspaceResourceId : logAnalyticsWorkspace .outputs .resourceId }]
754754 sku : aiFoundryAiServicesConfiguration .?sku ?? 'S0'
755755 kind : 'AIServices'
756- disableLocalAuth : false //Should be set to true for WAF aligned configuration
756+ disableLocalAuth : true //Should be set to true for WAF aligned configuration
757757 customSubDomainName : aiFoundryAiServicesResourceName
758758 apiProperties : {
759759 //staticsEnabled: false
@@ -782,11 +782,6 @@ module aiFoundryAiServices 'modules/ai-services.bicep' = if (aiFoundryAIservices
782782 ])
783783 : []
784784 roleAssignments : [
785- // {
786- // principalId: userAssignedIdentity.outputs.principalId
787- // principalType: 'ServicePrincipal'
788- // roleDefinitionIdOrName: 'Cognitive Services OpenAI User'
789- // }
790785 {
791786 principalId : containerApp .outputs .?systemAssignedMIPrincipalId !
792787 principalType : 'ServicePrincipal'
@@ -811,6 +806,18 @@ module aiFoundryAiServices 'modules/ai-services.bicep' = if (aiFoundryAIservices
811806 }
812807}
813808
809+ var roleAssignmentAiHubAiProjectAzureAiDeveloper = '${aiFoundryAiHubResourceName }-${aiFoundryAiProjectName }-CognitiveServicesOpenAIUser'
810+ module resourceRoleAssignmentAiHubAiProjectAzureAiDeveloper 'br/public:avm/ptn/authorization/resource-role-assignment:0.1.2' = if (aiFoundryAiHubEnabled && aiFoundryAIservicesEnabled ) {
811+ name : take ('avm.ptn.authorization.resource-role-assignment.${roleAssignmentAiHubAiProjectAzureAiDeveloper }' , 64 )
812+ params : {
813+ roleName : 'Azure AI Developer'
814+ roleDefinitionId : '64702f94-c441-49e6-a78b-ef80e0188fee'
815+ principalId : aiFoundryAiHub .outputs .?systemAssignedMIPrincipalId !
816+ principalType : 'ServicePrincipal'
817+ resourceId : aiFoundryAiProject .outputs .?resourceId
818+ }
819+ }
820+
814821// AI Foundry: storage account
815822// WAF best practices for Azure Blob Storage: https://learn.microsoft.com/en-us/azure/well-architected/service-guides/azure-blob-storage
816823var storageAccountPrivateDnsZones = {
@@ -844,7 +851,7 @@ var aiFoundryStorageAccountResourceName = aiFoundryStorageAccountConfiguration.?
844851 ''
845852)
846853
847- module aiFoundryStorageAccount 'br/public:avm/res/storage/storage-account:0.18.2 ' = if (aiFoundryStorageAccountEnabled ) {
854+ module aiFoundryStorageAccount 'br/public:avm/res/storage/storage-account:0.20.0 ' = if (aiFoundryStorageAccountEnabled ) {
848855 name : take ('avm.res.storage.storage-account.${aiFoundryStorageAccountResourceName }' , 64 )
849856 dependsOn : [
850857 privateDnsZonesAiFoundryStorageAccount
@@ -880,9 +887,13 @@ module aiFoundryStorageAccount 'br/public:avm/res/storage/storage-account:0.18.2
880887 : null
881888 roleAssignments : [
882889 {
883- principalId : userAssignedIdentity . outputs .principalId
890+ principalId : containerApp .? outputs .? systemAssignedMIPrincipalId !
884891 roleDefinitionIdOrName : 'Storage Blob Data Contributor'
885892 }
893+ {
894+ principalId : containerApp .?outputs .?systemAssignedMIPrincipalId !
895+ roleDefinitionIdOrName : '69566ab7-960f-475b-8e7c-b3118f30c6bd' //'Storage File Privileged Contributor'
896+ }
886897 ]
887898 }
888899}
@@ -896,7 +907,10 @@ var mlPrivateDnsZones = {
896907}
897908module privateDnsZonesAiFoundryWorkspaceHub 'br/public:avm/res/network/private-dns-zone:0.3.1' = [
898909 for zone in objectKeys (mlPrivateDnsZones ): if (virtualNetworkEnabled && aiFoundryAiHubEnabled ) {
899- name : take ('avm.res.network.private-dns-zone.ai-hub.${uniqueString (aiFoundryAiHubName ,zone )}.${solutionPrefix }' , 64 )
910+ name : take (
911+ 'avm.res.network.private-dns-zone.ai-hub.${uniqueString (aiFoundryAiHubResourceName ,zone )}.${solutionPrefix }' ,
912+ 64
913+ )
900914 params : {
901915 name : zone
902916 enableTelemetry : enableTelemetry
@@ -911,14 +925,14 @@ module privateDnsZonesAiFoundryWorkspaceHub 'br/public:avm/res/network/private-d
911925 }
912926]
913927var aiFoundryAiHubEnabled = aiFoundryAiHubConfiguration .?enabled ?? true
914- var aiFoundryAiHubName = aiFoundryAiHubConfiguration .?name ?? 'aih-${solutionPrefix }'
928+ var aiFoundryAiHubResourceName = aiFoundryAiHubConfiguration .?name ?? 'aih-${solutionPrefix }'
915929module aiFoundryAiHub 'modules/ai-hub.bicep' = if (aiFoundryAiHubEnabled ) {
916- name : take ('module.ai-hub.${aiFoundryAiHubName }' , 64 )
930+ name : take ('module.ai-hub.${aiFoundryAiHubResourceName }' , 64 )
917931 dependsOn : [
918932 privateDnsZonesAiFoundryWorkspaceHub
919933 ]
920934 params : {
921- name : aiFoundryAiHubName
935+ name : aiFoundryAiHubResourceName
922936 location : aiFoundryAiHubConfiguration .?location ?? azureOpenAILocation
923937 tags : aiFoundryAiHubConfiguration .?tags ?? tags
924938 sku : aiFoundryAiHubConfiguration .?sku ?? 'Basic'
@@ -931,8 +945,8 @@ module aiFoundryAiHub 'modules/ai-hub.bicep' = if (aiFoundryAiHubEnabled) {
931945 privateEndpoints : virtualNetworkEnabled
932946 ? [
933947 {
934- name : 'pep-${aiFoundryAiHubName }'
935- customNetworkInterfaceName : 'nic-${aiFoundryAiHubName }'
948+ name : 'pep-${aiFoundryAiHubResourceName }'
949+ customNetworkInterfaceName : 'nic-${aiFoundryAiHubResourceName }'
936950 service : mlTargetSubResource
937951 subnetResourceId : virtualNetworkEnabled
938952 ? aiFoundryAiHubConfiguration .?subnetResourceId ?? virtualNetwork .?outputs .?subnetResourceIds [0 ]
@@ -965,6 +979,7 @@ module aiFoundryAiProject 'br/public:avm/res/machine-learning-services/workspace
965979 sku : aiFoundryAiProjectConfiguration .?sku ?? 'Basic'
966980 kind : 'Project'
967981 hubResourceId : aiFoundryAiHub .outputs .resourceId
982+ managedIdentities : { systemAssigned : true }
968983 roleAssignments : [
969984 {
970985 principalId : containerApp .outputs .?systemAssignedMIPrincipalId !
@@ -975,6 +990,21 @@ module aiFoundryAiProject 'br/public:avm/res/machine-learning-services/workspace
975990 }
976991}
977992
993+ var roleAssignmentAiProjectAiServicesCognitiveServicesOpenAIUser = '${aiFoundryAiProjectName }-${aiFoundryAiHubResourceName }-CognitiveServicesOpenAIUser'
994+ module resourceRoleAssignmentAiProjectAiServicesCognitiveServicesOpenAIUser 'br/public:avm/ptn/authorization/resource-role-assignment:0.1.2' = if (aiFoundryAiHubEnabled && aiFoundryAIservicesEnabled ) {
995+ name : take (
996+ 'avm.ptn.authorization.resource-role-assignment.${roleAssignmentAiProjectAiServicesCognitiveServicesOpenAIUser }' ,
997+ 64
998+ )
999+ params : {
1000+ roleName : 'Cognitive Services OpenAI User'
1001+ roleDefinitionId : '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
1002+ principalId : aiFoundryAiProject .outputs .?systemAssignedMIPrincipalId !
1003+ principalType : 'ServicePrincipal'
1004+ resourceId : aiFoundryAiServices .outputs .resourceId
1005+ }
1006+ }
1007+
9781008// ========== Cosmos DB ========== //
9791009// WAF best practices for Cosmos DB: https://learn.microsoft.com/en-us/azure/well-architected/service-guides/cosmos-db
9801010module privateDnsZonesCosmosDb 'br/public:avm/res/network/private-dns-zone:0.7.0' = if (virtualNetworkEnabled ) {
@@ -1049,7 +1079,7 @@ module cosmosDb 'br/public:avm/res/document-db/database-account:0.12.0' = if (co
10491079 'EnableServerless'
10501080 ]
10511081 sqlRoleAssignmentsPrincipalIds : [
1052- //userAssignedIdentity .outputs.principalId
1082+ //userAssignedIdentityAIHub .outputs.principalId
10531083 containerApp .outputs .?systemAssignedMIPrincipalId
10541084 ]
10551085 sqlRoleDefinitions : [
@@ -1110,7 +1140,7 @@ module containerApp 'br/public:avm/res/app/container-app:0.14.2' = if (container
11101140 environmentResourceId : containerAppConfiguration .?environmentResourceId ?? containerAppEnvironment .outputs .resourceId
11111141 managedIdentities : {
11121142 systemAssigned : true //Replace with user assigned identity
1113- userAssignedResourceIds : [userAssignedIdentity .outputs .resourceId ]
1143+ // userAssignedResourceIds: [userAssignedIdentityAIHub .outputs.resourceId]
11141144 }
11151145 ingressTargetPort : containerAppConfiguration .?ingressTargetPort ?? 8000
11161146 ingressExternal : true
0 commit comments