@@ -207,6 +207,8 @@ param useAiProject bool = false
207
207
208
208
param webAppExists bool = false
209
209
210
+ var principalType = empty (runningOnGh ) ? 'User' : 'ServicePrincipal'
211
+
210
212
var resourceToken = toLower (uniqueString (subscription ().id , name , location ))
211
213
var prefix = '${toLower (name )}-${resourceToken }'
212
214
var tags = { 'azd-env-name' : name }
@@ -219,8 +221,6 @@ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
219
221
220
222
var postgresServerName = '${prefix }-postgresql'
221
223
var postgresDatabaseName = 'postgres'
222
- var postgresEntraAdministratorObjectId = principalId
223
- var postgresEntraAdministratorType = empty (runningOnGh ) ? 'User' : 'ServicePrincipal'
224
224
var postgresEntraAdministratorName = 'admin${uniqueString (resourceGroup .id , principalId )}'
225
225
226
226
module postgresServer 'core/database/postgresql/flexibleserver.bicep' = {
@@ -240,8 +240,8 @@ module postgresServer 'core/database/postgresql/flexibleserver.bicep' = {
240
240
version : '15'
241
241
authType : 'EntraOnly'
242
242
entraAdministratorName : postgresEntraAdministratorName
243
- entraAdministratorObjectId : postgresEntraAdministratorObjectId
244
- entraAdministratorType : postgresEntraAdministratorType
243
+ entraAdministratorObjectId : principalId
244
+ entraAdministratorType : principalType
245
245
allowAzureIPsFirewall : true
246
246
allowAllIPsFirewall : true // Necessary for post-provision script, can be disabled after
247
247
}
@@ -542,7 +542,7 @@ module ai 'core/ai/ai-foundry.bicep' = if (useAiProject) {
542
542
projectName : 'aiproject-${resourceToken }'
543
543
storageAccountName : storage .outputs .name
544
544
principalId : principalId
545
- principalType : empty ( runningOnGh ) ? 'User' : 'ServicePrincipal'
545
+ principalType : principalType
546
546
}
547
547
}
548
548
@@ -553,7 +553,7 @@ module openAIRoleUser 'core/security/role.bicep' = {
553
553
params : {
554
554
principalId : principalId
555
555
roleDefinitionId : '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd' // Cognitive Services OpenAI User
556
- principalType : empty ( runningOnGh ) ? 'User' : 'ServicePrincipal'
556
+ principalType : principalType
557
557
}
558
558
}
559
559
@@ -563,7 +563,7 @@ module azureAiUserRole 'core/security/role.bicep' = if (useAiProject && resource
563
563
params : {
564
564
principalId : principalId
565
565
roleDefinitionId : '53ca6127-db72-4b80-b1b0-d745d6d5456d' // Azure AI User
566
- principalType : empty ( runningOnGh ) ? 'User' : 'ServicePrincipal'
566
+ principalType : principalType
567
567
}
568
568
}
569
569
@@ -586,7 +586,7 @@ module appInsightsReaderRole 'core/security/role.bicep' = {
586
586
params : {
587
587
principalId : principalId
588
588
roleDefinitionId : '43d0d8ad-25c7-4714-9337-8ba259a9fe05' // Application Insights Component Reader
589
- principalType : 'User'
589
+ principalType : principalType
590
590
}
591
591
}
592
592
0 commit comments