powershell - 将标签应用到资源模板文件中的 Azure 资源组

标签 powershell azure azure-resource-manager

我正在使用 Powershell 从模板文件和参数文件创建 Azure 资源组。

New-AzureResourceGroup  -Name $groupName `
                    -TemplateFile $templateFile `
                    -TemplateParameterFile $paramFile `
                    -Location $location `
                    -Force -Verbose

在模板中,我在组内的资源上设置一些标签。

resourcegroup.json

    "parameters": {
        "environment": {
        "type": "string",
        "allowedValues": [
            "Dev",
            "Test",
            "QA",
            "Prod"
        ]}
    }
....
    "resources": [
    {
        ...
        "tags": {
            "Environment": "[parameters('environment')]",
        }
    }

我想将相同的标记值应用到资源组本身,但我没有在模板文件的架构中看到执行此操作的方法。我错过了什么吗?

最佳答案

至少现在,这是可能的:

{
      "type": "Microsoft.Resources/tags",
      "name": "default",
      "apiVersion": "2020-06-01",
      "dependsOn": [
        "resource1"
      ],
      "properties": {
        "tags": {
          "Tag1": "Value1",
          "Tag2": "Value2"
        }
      }
    }

文档引用 here

关于powershell - 将标签应用到资源模板文件中的 Azure 资源组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27994111/

相关文章:

powershell - 如何在一行上为用户输入日期和时间

Powershell 删除引号参数

azure - updateStartupCommandAndRuntimeStack 错误 azureweapp 部署

您没有权限的 Azure 添加应用程序注册

azure - Windows Azure 诊断代理已停止工作(异常 : StorageAccount is null)

azure - 将 Azure 应用服务部署到 URL : 404 + no worker is assigned to the app service plan. 该站点无法处理任何请求

azure - 在 Azure 中创建新角色分配时出错

arrays - Array.Find和IndexOf用于完全相同对象的多个元素

powershell - 通过Powershell进行CRM动态在线Odata查询

azure - 如何在 ARM 模板中打开 Azure SQL 数据库的审核和威胁检测?