azure - 二头肌 : How to concat tags

标签 azure azure-resource-manager azure-bicep

我正在使用 Bicep 脚本在 Mcirosoft Azure 中创建资源。

我已经定义了一个带有所有资源都相同的通用标签的变量。但是现在,当将此变量分配给资源时,我想添加更多仅适用于该资源的标签。

但是,我还没有找到方法来做到这一点。

最佳答案

您可以使用union合并对象的函数。

在此示例中,我使用通用标签定义了一个参数,并将对象与特定于资源的标签合并:

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'
  })
}

关于azure - 二头肌 : How to concat tags,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69348460/

相关文章:

azure - 将状态保留到 Azure Service Fabric 中的附加磁盘

Azure ARM 模板 vnet 对不同订阅进行对等

azure - 是否可以在不停机的情况下在两个 Azure Front Door 资源之间移动主机名?

azure - 检索 Synapse 服务主体的应用程序 ID 并使用 Bicep 添加为 AAS 管理员

azure - Virtual Machine Converter 3.1 找不到指纹

c# - 无法访问我的 Azure Web 应用程序的 "Authentication/Authorization"

c# - 一张表、多个 View 、一个 C# 类

azure - 使用 Bicep 将 API 管理专用 IP 地址输入专用 DNS 条目时,不需要模板函数 'reference'

azure - Azure SQL Serverless 数据库的二头肌模板

azure - Windows Azure 上单个 VM 内的 Window Server 2012 和 SQL Server 2012