Skip to content

Commit 98c243a

Browse files
Call the variable outside the resource
1 parent 0beee06 commit 98c243a

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

infra/main.bicep

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ param azureExistingAIProjectResourceId string = ''
118118
@description('Optional. Use this parameter to use an existing Log Analytics workspace resource ID. Defaults to empty string.')
119119
param existingLogAnalyticsWorkspaceId string = ''
120120

121+
var existingTags = resourceGroup().tags ?? {}
122+
121123
var allTags = union(
122124
{
123125
'azd-env-name': solutionName
@@ -158,7 +160,7 @@ resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = {
158160
name: 'default'
159161
properties: {
160162
tags: union(
161-
resourceGroup().tags ?? {},
163+
existingTags,
162164
allTags,
163165
{
164166
TemplateName: 'Code Modernization'

infra/main_custom.bicep

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ param azureExistingAIProjectResourceId string = ''
120120
@description('Optional. Use this parameter to use an existing Log Analytics workspace resource ID. Defaults to empty string.')
121121
param existingLogAnalyticsWorkspaceId string = ''
122122

123+
var existingTags = resourceGroup().tags ?? {}
124+
123125
var allTags = union(
124126
{
125127
'azd-env-name': solutionName
@@ -154,20 +156,21 @@ var modelDeployment = {
154156
@description('Optional. Tag, Created by user name. Defaults to user principal name or object ID.')
155157
param createdBy string = contains(deployer(), 'userPrincipalName')? split(deployer().userPrincipalName, '@')[0]: deployer().objectId
156158

159+
var resourceGroupTagsValue = union(
160+
existingTags,
161+
allTags,
162+
{
163+
TemplateName: 'Code Modernization'
164+
Type: enablePrivateNetworking ? 'WAF' : 'Non-WAF'
165+
CreatedBy: createdBy
166+
}
167+
)
157168

158169
// ========== Resource Group Tag ========== //
159170
resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = {
160171
name: 'default'
161172
properties: {
162-
tags: union(
163-
resourceGroup().tags ?? {},
164-
allTags,
165-
{
166-
TemplateName: 'Code Modernization'
167-
Type: enablePrivateNetworking ? 'WAF' : 'Non-WAF'
168-
CreatedBy: createdBy
169-
}
170-
)
173+
tags: resourceGroupTagsValue
171174
}
172175
}
173176

0 commit comments

Comments
 (0)