Problem
To build resources in Mcirosoft Azure, I’m using a Bicep script.
I’ve created a variable that has the common tags that apply to all resources. However, when I assign this variable to a resource, I’d like to add more tags that are specific to this resource.
But I haven’t yet figured out how to accomplish it.
Asked by Matthias Wirth
Solution #1
To unite objects, use the union function.
I’ve defined a parameter with common tags and merged the object with resource-specific tags in this example:
param commonTags object = {
commonTag1: 'commonTag1'
commonTag2: 'commonTag2'
}
resource storageAccount 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: 'my storage account name'
...
tags: union(commonTags, {
storageTag1: 'storageTag1'
storageTag2: 'storageTag2'
})
}
Answered by Thomas
Post is based on https://stackoverflow.com/questions/69348460/bicep-how-to-concat-tags