@@ -207,6 +207,8 @@ param useAiProject bool = false
207207
208208param webAppExists bool = false
209209
210+ var principalType = empty (runningOnGh ) ? 'User' : 'ServicePrincipal'
211+
210212var resourceToken = toLower (uniqueString (subscription ().id , name , location ))
211213var prefix = '${toLower (name )}-${resourceToken }'
212214var tags = { 'azd-env-name' : name }
@@ -219,8 +221,6 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
219221
220222var postgresServerName = '${prefix }-postgresql'
221223var postgresDatabaseName = 'postgres'
222- var postgresEntraAdministratorObjectId = principalId
223- var postgresEntraAdministratorType = empty (runningOnGh ) ? 'User' : 'ServicePrincipal'
224224var postgresEntraAdministratorName = 'admin${uniqueString (resourceGroup .id , principalId )}'
225225
226226module postgresServer 'core/database/postgresql/flexibleserver.bicep' = {
@@ -240,8 +240,8 @@ module postgresServer 'core/database/postgresql/flexibleserver.bicep' = {
240240 version : '15'
241241 authType : 'EntraOnly'
242242 entraAdministratorName : postgresEntraAdministratorName
243- entraAdministratorObjectId : postgresEntraAdministratorObjectId
244- entraAdministratorType : postgresEntraAdministratorType
243+ entraAdministratorObjectId : principalId
244+ entraAdministratorType : principalType
245245 allowAzureIPsFirewall : true
246246 allowAllIPsFirewall : true // Necessary for post-provision script, can be disabled after
247247 }
@@ -542,7 +542,7 @@ module ai 'core/ai/ai-foundry.bicep' = if (useAiProject) {
542542 projectName : 'aiproject-${resourceToken }'
543543 storageAccountName : storage .outputs .name
544544 principalId : principalId
545- principalType : empty ( runningOnGh ) ? 'User' : 'ServicePrincipal'
545+ principalType : principalType
546546 }
547547}
548548
@@ -553,7 +553,7 @@ module openAIRoleUser 'core/security/role.bicep' = {
553553 params : {
554554 principalId : principalId
555555 roleDefinitionId : '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd' // Cognitive Services OpenAI User
556- principalType : empty ( runningOnGh ) ? 'User' : 'ServicePrincipal'
556+ principalType : principalType
557557 }
558558}
559559
@@ -563,7 +563,7 @@ module azureAiUserRole 'core/security/role.bicep' = if (useAiProject && resource
563563 params : {
564564 principalId : principalId
565565 roleDefinitionId : '53ca6127-db72-4b80-b1b0-d745d6d5456d' // Azure AI User
566- principalType : empty ( runningOnGh ) ? 'User' : 'ServicePrincipal'
566+ principalType : principalType
567567 }
568568}
569569
@@ -586,7 +586,7 @@ module appInsightsReaderRole 'core/security/role.bicep' = {
586586 params : {
587587 principalId : principalId
588588 roleDefinitionId : '43d0d8ad-25c7-4714-9337-8ba259a9fe05' // Application Insights Component Reader
589- principalType : 'User'
589+ principalType : principalType
590590 }
591591}
592592
0 commit comments