@@ -7,66 +7,6 @@ param name string
77
88@minLength (1 )
99@description ('Primary location for all resources' )
10- // microsoft.insights/components has restricted regions
11- @allowed ([
12- 'eastus'
13- 'southcentralus'
14- 'northeurope'
15- 'westeurope'
16- 'southeastasia'
17- 'westus2'
18- 'uksouth'
19- 'canadacentral'
20- 'centralindia'
21- 'japaneast'
22- 'australiaeast'
23- 'koreacentral'
24- 'francecentral'
25- 'centralus'
26- 'eastus2'
27- 'eastasia'
28- 'westus'
29- 'southafricanorth'
30- 'northcentralus'
31- 'brazilsouth'
32- 'switzerlandnorth'
33- 'norwayeast'
34- 'norwaywest'
35- 'australiasoutheast'
36- 'australiacentral2'
37- 'germanywestcentral'
38- 'switzerlandwest'
39- 'uaecentral'
40- 'ukwest'
41- 'japanwest'
42- 'brazilsoutheast'
43- 'uaenorth'
44- 'australiacentral'
45- 'southindia'
46- 'westus3'
47- 'koreasouth'
48- 'swedencentral'
49- 'canadaeast'
50- 'jioindiacentral'
51- 'jioindiawest'
52- 'qatarcentral'
53- 'southafricawest'
54- 'germanynorth'
55- 'polandcentral'
56- 'israelcentral'
57- 'italynorth'
58- 'mexicocentral'
59- 'spaincentral'
60- 'newzealandnorth'
61- 'chilecentral'
62- 'indonesiacentral'
63- 'malaysiawest'
64- ])
65- @metadata ({
66- azd : {
67- type : 'location'
68- }
69- })
7010param location string
7111
7212@description ('Whether the deployment is running on GitHub Actions' )
@@ -207,20 +147,18 @@ param useAiProject bool = false
207147
208148param webAppExists bool = false
209149
210- var principalType = empty (runningOnGh ) ? 'User' : 'ServicePrincipal'
211-
212150var resourceToken = toLower (uniqueString (subscription ().id , name , location ))
213151var prefix = '${toLower (name )}-${resourceToken }'
214152var tags = { 'azd-env-name' : name }
215153
216- resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
217- name : '${name }-rg'
218- location : location
219- tags : tags
154+ // ✅ Use existing ResourceGroup1 instead of creating a new one
155+ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' existing = {
156+ name : 'ResourceGroup1'
220157}
221-
222158var postgresServerName = '${prefix }-postgresql'
223159var postgresDatabaseName = 'postgres'
160+ var postgresEntraAdministratorObjectId = principalId
161+ var postgresEntraAdministratorType = empty (runningOnGh ) ? 'User' : 'ServicePrincipal'
224162var postgresEntraAdministratorName = 'admin${uniqueString (resourceGroup .id , principalId )}'
225163
226164module postgresServer 'core/database/postgresql/flexibleserver.bicep' = {
@@ -240,8 +178,8 @@ module postgresServer 'core/database/postgresql/flexibleserver.bicep' = {
240178 version : '15'
241179 authType : 'EntraOnly'
242180 entraAdministratorName : postgresEntraAdministratorName
243- entraAdministratorObjectId : principalId
244- entraAdministratorType : principalType
181+ entraAdministratorObjectId : postgresEntraAdministratorObjectId
182+ entraAdministratorType : postgresEntraAdministratorType
245183 allowAzureIPsFirewall : true
246184 allowAllIPsFirewall : true // Necessary for post-provision script, can be disabled after
247185 }
@@ -542,7 +480,7 @@ module ai 'core/ai/ai-foundry.bicep' = if (useAiProject) {
542480 projectName : 'aiproject-${resourceToken }'
543481 storageAccountName : storage .outputs .name
544482 principalId : principalId
545- principalType : principalType
483+ principalType : empty ( runningOnGh ) ? 'User' : 'ServicePrincipal'
546484 }
547485}
548486
@@ -553,7 +491,7 @@ module openAIRoleUser 'core/security/role.bicep' = {
553491 params : {
554492 principalId : principalId
555493 roleDefinitionId : '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd' // Cognitive Services OpenAI User
556- principalType : principalType
494+ principalType : empty ( runningOnGh ) ? 'User' : 'ServicePrincipal'
557495 }
558496}
559497
@@ -563,7 +501,7 @@ module azureAiUserRole 'core/security/role.bicep' = if (useAiProject && resource
563501 params : {
564502 principalId : principalId
565503 roleDefinitionId : '53ca6127-db72-4b80-b1b0-d745d6d5456d' // Azure AI User
566- principalType : principalType
504+ principalType : empty ( runningOnGh ) ? 'User' : 'ServicePrincipal'
567505 }
568506}
569507
@@ -586,7 +524,7 @@ module appInsightsReaderRole 'core/security/role.bicep' = {
586524 params : {
587525 principalId : principalId
588526 roleDefinitionId : '43d0d8ad-25c7-4714-9337-8ba259a9fe05' // Application Insights Component Reader
589- principalType : principalType
527+ principalType : 'User'
590528 }
591529}
592530
0 commit comments