@@ -9,7 +9,8 @@ param name string
9
9
@description ('Primary location for all resources' )
10
10
param location string
11
11
12
- @description ('Name of the existing resource group' )
12
+ @description ('Name of the existing resource group to use' )
13
+ @minLength (1 )
13
14
param existingResourceGroupName string
14
15
15
16
@description ('Whether the deployment is running on GitHub Actions' )
@@ -70,10 +71,6 @@ var chatConfig = {
70
71
deploymentCapacity : chatDeploymentCapacity != 0 ? chatDeploymentCapacity : 30
71
72
}
72
73
73
- // Reference the existing resource group
74
- resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' existing = {
75
- name : existingResourceGroupName
76
- }
77
74
78
75
param embedModelName string = ''
79
76
param embedDeploymentName string = ''
@@ -95,12 +92,12 @@ var resourceToken = toLower(uniqueString(subscription().id, name, location))
95
92
var prefix = '${name }-${resourceToken }'
96
93
var tags = { 'azd-env-name' : name }
97
94
98
- resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
99
- name : '${name }-rg'
100
- location : location
101
- tags : tags
95
+ // Use the existing resource group
96
+ resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' existing = {
97
+ name : existingResourceGroupName
102
98
}
103
99
100
+ // PostgreSQL Server
104
101
var postgresServerName = '${prefix }-postgresql'
105
102
var postgresDatabaseName = 'postgres'
106
103
var postgresEntraAdministratorObjectId = principalId
@@ -109,7 +106,7 @@ var postgresEntraAdministratorName = 'admin${uniqueString(resourceGroup.id, prin
109
106
110
107
module postgresServer 'core/database/postgresql/flexibleserver.bicep' = {
111
108
name : 'postgresql'
112
- scope : resourceGroup
109
+ scope : existingResourceGroup
113
110
params : {
114
111
name : postgresServerName
115
112
location : location
@@ -134,7 +131,7 @@ module postgresServer 'core/database/postgresql/flexibleserver.bicep' = {
134
131
// Monitor application with Azure Monitor
135
132
module monitoring 'core/monitor/monitoring.bicep' = {
136
133
name : 'monitoring'
137
- scope : resourceGroup
134
+ scope : existingResourceGroup
138
135
params : {
139
136
location : location
140
137
tags : tags
@@ -147,7 +144,7 @@ module monitoring 'core/monitor/monitoring.bicep' = {
147
144
// Container apps host (including container registry)
148
145
module containerApps 'core/host/container-apps.bicep' = {
149
146
name : 'container-apps'
150
- scope : resourceGroup
147
+ scope : existingResourceGroup
151
148
params : {
152
149
name : 'app'
153
150
location : location
@@ -247,7 +244,7 @@ var secrets = !empty(azureOpenAIKey) ? {
247
244
248
245
module web 'web.bicep' = {
249
246
name : 'web'
250
- scope : resourceGroup
247
+ scope : existingResourceGroup
251
248
params : {
252
249
name : webAppName
253
250
location : location
@@ -261,14 +258,10 @@ module web 'web.bicep' = {
261
258
}
262
259
}
263
260
264
- resource openAIResourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' existing =
265
- if (!empty (openAIResourceGroupName )) {
266
- name : !empty (openAIResourceGroupName ) ? openAIResourceGroupName : resourceGroup .name
267
- }
268
261
269
262
module openAI 'core/ai/cognitiveservices.bicep' = if (deployAzureOpenAI ) {
270
263
name : 'openai'
271
- scope : openAIResourceGroup
264
+ scope : existingResourceGroup
272
265
params : {
273
266
name : '${prefix }-openai'
274
267
location : openAILocation
@@ -309,7 +302,7 @@ module openAI 'core/ai/cognitiveservices.bicep' = if (deployAzureOpenAI) {
309
302
// USER ROLES
310
303
module openAIRoleUser 'core/security/role.bicep' =
311
304
if (empty (runningOnGh )) {
312
- scope : openAIResourceGroup
305
+ scope : existingResourceGroup
313
306
name : 'openai-role-user'
314
307
params : {
315
308
principalId : principalId
@@ -320,7 +313,7 @@ module openAIRoleUser 'core/security/role.bicep' =
320
313
321
314
// Backend roles
322
315
module openAIRoleBackend 'core/security/role.bicep' = {
323
- scope : openAIResourceGroup
316
+ scope : existingResourceGroup
324
317
name : 'openai-role-backend'
325
318
params : {
326
319
principalId : web .outputs .SERVICE_WEB_IDENTITY_PRINCIPAL_ID
0 commit comments