Skip to content

Commit 7606403

Browse files
committed
add tagsbyresource ui element
1 parent 1ab81e2 commit 7606403

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
34 KB
Loading
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: Azure TagsByResource UI element
3+
description: Describes the Microsoft.Common.TagsByResource UI element for Azure portal. Use to apply tags to a resource during deployment.
4+
author: tfitzmac
5+
6+
ms.service: managed-applications
7+
ms.topic: reference
8+
ms.date: 11/11/2019
9+
ms.author: tomfitz
10+
11+
---
12+
13+
# Microsoft.Common.TagsByResource UI element
14+
15+
A control for associating [tags](../azure-resource-manager/resource-group-using-tags.md) with the resources in a deployment.
16+
17+
## UI sample
18+
19+
![Microsoft.Common.DropDown](./media/managed-application-elements/microsoft.common.tagsbyresource.png)
20+
21+
## Schema
22+
23+
```json
24+
{
25+
"name": "element1",
26+
"type": "Microsoft.Common.TagsByResource",
27+
"resources": [
28+
"Microsoft.Storage/storageAccounts",
29+
"Microsoft.Compute/virtualMachines"
30+
]
31+
}
32+
```
33+
34+
## Sample output
35+
36+
```json
37+
{
38+
"Microsoft.Storage/storageAccounts": {
39+
"Dept": "Finance",
40+
"Environment": "Production"
41+
},
42+
"Microsoft.Compute/virtualMachines": {
43+
"Dept": "Finance"
44+
}
45+
}
46+
```
47+
48+
## Remarks
49+
50+
- At least one item in the `resources` array must be specified.
51+
- Each element in `resources` must be a fully qualified resource type. Elements included here appear in the **Resource** dropdown. The user can apply tags to any resources in the dropdown.
52+
- 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 as shown in the following example:
53+
54+
```json
55+
"parameters": {
56+
"tagsByResource": { "type": "object", "defaultValue": {} }
57+
}
58+
```
59+
60+
And for each resource that can be tagged, include a tags property that accesses the parameter values for that type:
61+
62+
```json
63+
{
64+
"name": "saName1",
65+
"type": "Microsoft.Storage/storageAccounts",
66+
"tags": "[ if(contains(parameters('tagsByResource'), 'Microsoft.Storage/storageAccounts'), parameters('tagsByResource')['Microsoft.Storage/storageAccounts'], json('{}')) ]",
67+
...
68+
```
69+
70+
- Use the [if](../azure-resource-manager/resource-group-template-functions-logical.md#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.
71+
72+
## Next steps
73+
74+
- For an introduction to creating UI definitions, see [Getting started with CreateUiDefinition](create-uidefinition-overview.md).
75+
- For a description of common properties in UI elements, see [CreateUiDefinition elements](create-uidefinition-elements.md).

0 commit comments

Comments
 (0)