Skip to content

Commit 9e731de

Browse files
fix: Set Cosmos DB deployment location to the primary region
2 parents d3f26a7 + 604040e commit 9e731de

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

infra/main.bicep

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,18 @@ param createdBy string = empty(deployer().userPrincipalName) ? '' : split(deploy
112112
resource resourceGroupTags 'Microsoft.Resources/tags@2021-04-01' = {
113113
name: 'default'
114114
properties: {
115-
tags: {
116-
... tags
117-
TemplateName: 'KM Generic'
118-
CreatedBy: createdBy
119-
}
115+
tags: union(
116+
reference(
117+
resourceGroup().id,
118+
'2021-04-01',
119+
'Full'
120+
).tags ?? {},
121+
{
122+
TemplateName: 'KM Generic'
123+
CreatedBy: createdBy
124+
},
125+
tags
126+
)
120127
}
121128
}
122129

@@ -187,7 +194,7 @@ module cosmosDBModule 'deploy_cosmos_db.bicep' = {
187194
name: 'deploy_cosmos_db'
188195
params: {
189196
accountName: 'cosmos-${solutionSuffix}'
190-
solutionLocation: secondaryLocation
197+
solutionLocation: solutionLocation
191198
keyVaultName: kvault.outputs.keyvaultName
192199
tags : tags
193200
}

infra/main.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"_generator": {
66
"name": "bicep",
77
"version": "0.37.4.10188",
8-
"templateHash": "7263803858241829495"
8+
"templateHash": "4854945365103887323"
99
}
1010
},
1111
"parameters": {
@@ -166,6 +166,13 @@
166166
"metadata": {
167167
"description": "Optional. A unique text value for the solution. This is used to ensure resource names are unique for global resources. Defaults to a 5-character substring of the unique string generated from the subscription ID, resource group name, and solution name."
168168
}
169+
},
170+
"createdBy": {
171+
"type": "string",
172+
"defaultValue": "[if(empty(deployer().userPrincipalName), '', split(deployer().userPrincipalName, '@')[0])]",
173+
"metadata": {
174+
"description": "Optional created by user name"
175+
}
169176
}
170177
},
171178
"variables": {
@@ -180,7 +187,7 @@
180187
"apiVersion": "2021-04-01",
181188
"name": "default",
182189
"properties": {
183-
"tags": "[shallowMerge(createArray(parameters('tags'), createObject('TemplateName', 'KM Generic')))]"
190+
"tags": "[union(coalesce(reference(resourceGroup().id, '2021-04-01', 'Full').tags, createObject()), createObject('TemplateName', 'KM Generic', 'CreatedBy', parameters('createdBy')), parameters('tags'))]"
184191
}
185192
},
186193
{
@@ -2258,7 +2265,7 @@
22582265
"value": "[format('cosmos-{0}', variables('solutionSuffix'))]"
22592266
},
22602267
"solutionLocation": {
2261-
"value": "[parameters('secondaryLocation')]"
2268+
"value": "[variables('solutionLocation')]"
22622269
},
22632270
"keyVaultName": {
22642271
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_keyvault'), '2022-09-01').outputs.keyvaultName.value]"

0 commit comments

Comments
 (0)