@@ -20,6 +20,10 @@ param existingLogAnalyticsWorkspaceId string = ''
2020
2121param azureopenaiVersion string = '2025-01-01-preview'
2222
23+ //Get the current deployer's information
24+ var deployerInfo = deployer ()
25+ var deployingUserPrincipalId = deployerInfo .objectId
26+
2327// Restricting deployment to only supported Azure OpenAI regions validated with GPT-4o model
2428@metadata ({
2529 azd : {
@@ -812,6 +816,36 @@ module cogServiceRoleAssignmentsExisting './modules/role.bicep' = if(useExisting
812816 scope : resourceGroup ( split (existingFoundryProjectResourceId , '/' )[2 ], split (existingFoundryProjectResourceId , '/' )[4 ])
813817}
814818
819+ // User Role Assignment for Azure OpenAI - New Resources
820+ module userOpenAiRoleAssignment './modules/role.bicep' = if (aiFoundryAIservicesEnabled && !useExistingResourceId ) {
821+ name : take ('user-openai-${uniqueString (deployingUserPrincipalId , aiFoundryAiServicesResourceName )}' , 64 )
822+ params : {
823+ name : 'user-openai-${uniqueString (deployingUserPrincipalId , aiFoundryAiServicesResourceName )}'
824+ principalId : deployingUserPrincipalId
825+ aiServiceName : aiFoundryAiServices .outputs .name
826+ principalType : 'User'
827+ }
828+ scope : resourceGroup (subscription ().subscriptionId , resourceGroup ().name )
829+ dependsOn : [
830+ aiFoundryAiServices
831+ ]
832+ }
833+
834+ // User Role Assignment for Azure OpenAI - Existing Resources
835+ module userOpenAiRoleAssignmentExisting './modules/role.bicep' = if (aiFoundryAIservicesEnabled && useExistingResourceId ) {
836+ name : take ('user-openai-existing-${uniqueString (deployingUserPrincipalId , aiFoundryAiServicesResourceName )}' , 64 )
837+ params : {
838+ name : 'user-openai-existing-${uniqueString (deployingUserPrincipalId , aiFoundryAiServicesResourceName )}'
839+ principalId : deployingUserPrincipalId
840+ aiServiceName : aiFoundryAiServices .outputs .name
841+ principalType : 'User'
842+ }
843+ scope : resourceGroup (split (existingFoundryProjectResourceId , '/' )[2 ], split (existingFoundryProjectResourceId , '/' )[4 ])
844+ dependsOn : [
845+ aiFoundryAiServices
846+ ]
847+ }
848+
815849// ========== Cosmos DB ========== //
816850// WAF best practices for Cosmos DB: https://learn.microsoft.com/en-us/azure/well-architected/service-guides/cosmos-db
817851module privateDnsZonesCosmosDb 'br/public:avm/res/network/private-dns-zone:0.7.0' = if (virtualNetworkEnabled ) {
@@ -886,9 +920,11 @@ module cosmosDb 'br/public:avm/res/document-db/database-account:0.12.0' = if (co
886920 capabilitiesToAdd : [
887921 'EnableServerless'
888922 ]
889- sqlRoleAssignmentsPrincipalIds : [
890- containerApp .outputs .?systemAssignedMIPrincipalId
891- ]
923+
924+ sqlRoleAssignmentsPrincipalIds : concat (
925+ [containerApp .outputs .?systemAssignedMIPrincipalId ],
926+ [deployingUserPrincipalId ]
927+ )
892928 sqlRoleDefinitions : [
893929 {
894930 // Replace this with built-in role definition Cosmos DB Built-in Data Contributor: https://docs.azure.cn/en-us/cosmos-db/nosql/security/reference-data-plane-roles#cosmos-db-built-in-data-contributor
0 commit comments