Skip to content

Commit db8e98f

Browse files
Update main.bicep
1 parent ff8b43b commit db8e98f

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

infra/main.bicep

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ param name string
99
@description('Primary location for all resources')
1010
param location string
1111

12-
@description('Name of the existing resource group')
12+
@description('Name of the existing resource group to use')
13+
@minLength(1)
1314
param existingResourceGroupName string
1415

1516
@description('Whether the deployment is running on GitHub Actions')
@@ -70,10 +71,6 @@ var chatConfig = {
7071
deploymentCapacity: chatDeploymentCapacity != 0 ? chatDeploymentCapacity : 30
7172
}
7273

73-
// Reference the existing resource group
74-
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' existing = {
75-
name: existingResourceGroupName
76-
}
7774

7875
param embedModelName string = ''
7976
param embedDeploymentName string = ''
@@ -95,12 +92,12 @@ var resourceToken = toLower(uniqueString(subscription().id, name, location))
9592
var prefix = '${name}-${resourceToken}'
9693
var tags = { 'azd-env-name': name }
9794

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
10298
}
10399

100+
// PostgreSQL Server
104101
var postgresServerName = '${prefix}-postgresql'
105102
var postgresDatabaseName = 'postgres'
106103
var postgresEntraAdministratorObjectId = principalId
@@ -109,7 +106,7 @@ var postgresEntraAdministratorName = 'admin${uniqueString(resourceGroup.id, prin
109106

110107
module postgresServer 'core/database/postgresql/flexibleserver.bicep' = {
111108
name: 'postgresql'
112-
scope: resourceGroup
109+
scope: existingResourceGroup
113110
params: {
114111
name: postgresServerName
115112
location: location
@@ -134,7 +131,7 @@ module postgresServer 'core/database/postgresql/flexibleserver.bicep' = {
134131
// Monitor application with Azure Monitor
135132
module monitoring 'core/monitor/monitoring.bicep' = {
136133
name: 'monitoring'
137-
scope: resourceGroup
134+
scope: existingResourceGroup
138135
params: {
139136
location: location
140137
tags: tags
@@ -147,7 +144,7 @@ module monitoring 'core/monitor/monitoring.bicep' = {
147144
// Container apps host (including container registry)
148145
module containerApps 'core/host/container-apps.bicep' = {
149146
name: 'container-apps'
150-
scope: resourceGroup
147+
scope: existingResourceGroup
151148
params: {
152149
name: 'app'
153150
location: location
@@ -247,7 +244,7 @@ var secrets = !empty(azureOpenAIKey) ? {
247244

248245
module web 'web.bicep' = {
249246
name: 'web'
250-
scope: resourceGroup
247+
scope: existingResourceGroup
251248
params: {
252249
name: webAppName
253250
location: location
@@ -261,14 +258,10 @@ module web 'web.bicep' = {
261258
}
262259
}
263260

264-
resource openAIResourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' existing =
265-
if (!empty(openAIResourceGroupName)) {
266-
name: !empty(openAIResourceGroupName) ? openAIResourceGroupName : resourceGroup.name
267-
}
268261

269262
module openAI 'core/ai/cognitiveservices.bicep' = if (deployAzureOpenAI) {
270263
name: 'openai'
271-
scope: openAIResourceGroup
264+
scope: existingResourceGroup
272265
params: {
273266
name: '${prefix}-openai'
274267
location: openAILocation
@@ -309,7 +302,7 @@ module openAI 'core/ai/cognitiveservices.bicep' = if (deployAzureOpenAI) {
309302
// USER ROLES
310303
module openAIRoleUser 'core/security/role.bicep' =
311304
if (empty(runningOnGh)) {
312-
scope: openAIResourceGroup
305+
scope: existingResourceGroup
313306
name: 'openai-role-user'
314307
params: {
315308
principalId: principalId
@@ -320,7 +313,7 @@ module openAIRoleUser 'core/security/role.bicep' =
320313

321314
// Backend roles
322315
module openAIRoleBackend 'core/security/role.bicep' = {
323-
scope: openAIResourceGroup
316+
scope: existingResourceGroup
324317
name: 'openai-role-backend'
325318
params: {
326319
principalId: web.outputs.SERVICE_WEB_IDENTITY_PRINCIPAL_ID

0 commit comments

Comments
 (0)