【问题标题】:Apply tags to Azure resource group within resource template file将标签应用到资源模板文件中的 Azure 资源组
【发布时间】:2020-07-15 20:50:19
【问题描述】:

我正在使用 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')]",
        }
    }

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

【问题讨论】:

    标签: powershell azure azure-resource-manager


    【解决方案1】:

    现在至少,这是可能的:

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

    文档参考here

    【讨论】:

      【解决方案2】:

      AFAIK,您必须使用 azure Powershell command-let 将标签添加到您的 Azure 资源组。无法通过模板文件完成。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-02-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-01-17
        • 1970-01-01
        相关资源
        最近更新 更多