@@ -53,6 +53,7 @@ param azureAiServiceLocation string
5353 'westus3'
5454])
5555@description ('Required. Azure region for AI model deployment. Should match azureAiServiceLocation for optimal performance.' )
56+ #disable-next-line no-unused-params
5657param aiDeploymentLocation string = azureAiServiceLocation
5758
5859@description ('Optional. The host (excluding https://) of an existing container registry. This is the `loginServer` when using Azure Container Registry.' )
@@ -103,6 +104,11 @@ param createdBy string = contains(deployer(), 'userPrincipalName')
103104 ? split (deployer ().userPrincipalName , '@' )[0 ]
104105 : deployer ().objectId
105106
107+ // Get the current deployer's information for local debugging permissions
108+ var deployerInfo = deployer ()
109+ var deployingUserPrincipalId = deployerInfo .objectId
110+ var deployingUserType = !empty (deployerInfo .userPrincipalName ) ? 'User' : 'ServicePrincipal'
111+
106112@description ('Optional. Resource ID of an existing Foundry project' )
107113param existingFoundryProjectResourceId string = ''
108114
@@ -469,6 +475,17 @@ module storageAccount 'br/public:avm/res/storage/storage-account:0.20.0' = {
469475 principalId : appIdentity .outputs .principalId
470476 principalType : 'ServicePrincipal'
471477 }
478+ // Add deployer permissions
479+ {
480+ roleDefinitionIdOrName : 'Storage Blob Data Contributor'
481+ principalId : deployingUserPrincipalId
482+ principalType : deployingUserType
483+ }
484+ {
485+ roleDefinitionIdOrName : 'Storage Queue Data Contributor'
486+ principalId : deployingUserPrincipalId
487+ principalType : deployingUserType
488+ }
472489 ]
473490 // WAF aligned networking
474491 networkAcls : {
@@ -655,6 +672,12 @@ module cosmosDb 'br/public:avm/res/document-db/database-account:0.15.0' = {
655672 principalType : 'ServicePrincipal'
656673 roleDefinitionIdOrName : 'DocumentDB Account Contributor'
657674 }
675+ // Add deployer for local debugging
676+ {
677+ principalId : deployingUserPrincipalId
678+ principalType : deployingUserType
679+ roleDefinitionIdOrName : 'DocumentDB Account Contributor'
680+ }
658681 ]
659682 // Create custom data plane role definition and assignment
660683 dataPlaneRoleDefinitions : [
@@ -669,6 +692,8 @@ module cosmosDb 'br/public:avm/res/document-db/database-account:0.15.0' = {
669692 ]
670693 assignments : [
671694 { principalId : appIdentity .outputs .principalId }
695+ // ADD THIS for local debugging support:
696+ { principalId : deployingUserPrincipalId }
672697 ]
673698 }
674699 ]
@@ -699,7 +724,7 @@ module existingAiFoundryAiServicesDeployments 'modules/ai-services-deployments.b
699724 name : take ('module.ai-services-model-deployments.${existingAiFoundryAiServices .name }' , 64 )
700725 scope : resourceGroup (aiFoundryAiServicesSubscriptionId , aiFoundryAiServicesResourceGroupName )
701726 params : {
702- name : existingAiFoundryAiServices . name
727+ name : aiFoundryAiServicesResourceName // Fix: use variable instead of resource reference
703728 deployments : [
704729 {
705730 name : aiModelDeploymentName
@@ -715,6 +740,7 @@ module existingAiFoundryAiServicesDeployments 'modules/ai-services-deployments.b
715740 }
716741 ]
717742 roleAssignments : [
743+ // Service Principal permissions
718744 {
719745 principalId : appIdentity .outputs .principalId
720746 principalType : 'ServicePrincipal'
@@ -723,12 +749,23 @@ module existingAiFoundryAiServicesDeployments 'modules/ai-services-deployments.b
723749 {
724750 principalId : appIdentity .outputs .principalId
725751 principalType : 'ServicePrincipal'
726- roleDefinitionIdOrName : '64702f94-c441-49e6-a78b-ef80e0188fee' // Azure AI Developer
752+ roleDefinitionIdOrName : '64702f94-c441-49e6-a78b-ef80e0188fee'
727753 }
728754 {
729755 principalId : appIdentity .outputs .principalId
730756 principalType : 'ServicePrincipal'
731- roleDefinitionIdOrName : '53ca6127-db72-4b80-b1b0-d745d6d5456d' // Azure AI User
757+ roleDefinitionIdOrName : '53ca6127-db72-4b80-b1b0-d745d6d5456d'
758+ }
759+ // Deployer permissions
760+ {
761+ principalId : deployingUserPrincipalId
762+ principalType : deployingUserType
763+ roleDefinitionIdOrName : 'Cognitive Services OpenAI Contributor'
764+ }
765+ {
766+ principalId : deployingUserPrincipalId
767+ principalType : deployingUserType
768+ roleDefinitionIdOrName : 'Cognitive Services User'
732769 }
733770 ]
734771 }
@@ -746,6 +783,7 @@ module aiFoundry 'br/public:avm/ptn/ai-ml/ai-foundry:0.4.0' = if(!useExistingAiF
746783 accountName :aiFoundryAiServicesResourceName
747784 allowProjectManagement : true
748785 roleAssignments : [
786+ // Service Principal permissions
749787 {
750788 principalId : appIdentity .outputs .principalId
751789 principalType : 'ServicePrincipal'
@@ -761,6 +799,17 @@ module aiFoundry 'br/public:avm/ptn/ai-ml/ai-foundry:0.4.0' = if(!useExistingAiF
761799 principalType : 'ServicePrincipal'
762800 roleDefinitionIdOrName : '53ca6127-db72-4b80-b1b0-d745d6d5456d' // Azure AI User
763801 }
802+ // Deployer permissions for local debugging
803+ {
804+ principalId : deployingUserPrincipalId
805+ principalType : deployingUserType
806+ roleDefinitionIdOrName : 'Cognitive Services OpenAI Contributor'
807+ }
808+ {
809+ principalId : deployingUserPrincipalId
810+ principalType : deployingUserType
811+ roleDefinitionIdOrName : 'Cognitive Services User'
812+ }
764813 ]
765814 // Remove networking configuration to avoid AML workspace creation issues
766815 networking : enablePrivateNetworking ? {
@@ -791,7 +840,7 @@ module aiFoundry 'br/public:avm/ptn/ai-ml/ai-foundry:0.4.0' = if(!useExistingAiF
791840 }
792841}
793842
794- var aiServicesName = useExistingAiFoundryAiProject ? existingAiFoundryAiServices .name : aiFoundry . outputs . aiServicesName
843+ var aiServicesName = useExistingAiFoundryAiProject ? existingAiFoundryAiServices .name : aiFoundryAiServicesResourceName
795844module appConfiguration 'br/public:avm/res/app-configuration/configuration-store:0.9.1' = {
796845 name : take ('avm.res.app-config.store.${solutionSuffix }' , 64 )
797846 params : {
@@ -898,6 +947,8 @@ module appConfiguration 'br/public:avm/res/app-configuration/configuration-store
898947 sku : 'Standard'
899948 publicNetworkAccess : 'Enabled'
900949 }
950+ // Add explicit dependency
951+ dependsOn : useExistingAiFoundryAiProject ? [] : [aiFoundry ]
901952}
902953
903954module avmAppConfigUpdated 'br/public:avm/res/app-configuration/configuration-store:0.6.3' = if (enablePrivateNetworking ) {
@@ -971,7 +1022,7 @@ module containerAppsEnvironment 'br/public:avm/res/app/managed-environment:0.11.
9711022 platformReservedDnsIP : '172.17.17.17'
9721023 zoneRedundant : (enablePrivateNetworking ) ? true : false // Enable zone redundancy if private networking is enabled
9731024 infrastructureSubnetResourceId : (enablePrivateNetworking )
974- ? virtualNetwork .outputs .containersSubnetResourceId // Use the container app subnet
1025+ ? virtualNetwork ! .outputs .containersSubnetResourceId // Use the container app subnet
9751026 : null // Use the container app subnet
9761027 }
9771028}
@@ -1210,3 +1261,7 @@ output AZURE_SUBSCRIPTION_ID string = subscription().subscriptionId
12101261
12111262@description ('The Azure resource group name.' )
12121263output AZURE_RESOURCE_GROUP string = resourceGroup ().name
1264+
1265+ // Log deployer information for debugging
1266+ output deployerObjectId string = deployingUserPrincipalId
1267+ output deployerType string = deployingUserType
0 commit comments