Skip to content

Latest commit

 

History

History
70 lines (54 loc) · 2.36 KB

microsoft-common-tagsbyresource.md

File metadata and controls

70 lines (54 loc) · 2.36 KB
title description ms.topic ms.date
TagsByResource UI element
Describes the Microsoft.Common.TagsByResource UI element for Azure portal. Use to apply tags to a resource during deployment.
reference
06/24/2024

Microsoft.Common.TagsByResource UI element

A control for associating tags with the resources in a deployment.

UI sample

:::image type="content" source="./media/managed-application-elements/microsoft-common-tagsbyresource.png" alt-text="Screenshot of Microsoft.Common.TagsByResource UI element in a deployment.":::

Schema

{
  "name": "element1",
  "type": "Microsoft.Common.TagsByResource",
  "resources": [
    "Microsoft.Storage/storageAccounts",
    "Microsoft.Compute/virtualMachines"
  ]
}

Sample output

{
  "Microsoft.Storage/storageAccounts": {
    "Dept": "Finance",
    "Environment": "Production"
  },
  "Microsoft.Compute/virtualMachines": {
    "Dept": "Finance"
  }
}

Remarks

  • At least one item in the resources array must be specified.

  • Each element in resources must be a fully qualified resource type. These elements appear in the Resource dropdown, and are taggable by the user.

  • The output of the control is formatted for easy assignment of tag values in an Azure Resource Manager template. To receive the control's output in a template, include a parameter in your template as shown in the following example:

    "parameters": {
      "tagsByResource": { "type": "object", "defaultValue": {} }
    }

    For each resource that can be tagged, assign the tags property to the parameter value for that resource type:

    {
      "name": "saName1",
      "type": "Microsoft.Storage/storageAccounts",
      "tags": "[ if(contains(parameters('tagsByResource'), 'Microsoft.Storage/storageAccounts'), parameters('tagsByResource')['Microsoft.Storage/storageAccounts'], json('{}')) ]",
      ...
  • Use the if function when accessing the tagsByResource parameter. It enables you to assign an empty object when no tags are assigned to the given resource type.

Next steps