Skip to content

Commit 5276f00

Browse files
authored
Merge pull request Azure#11155 from Azure/tagsOnGetAzResource
Shows tags table in output for Get-AzResource
2 parents 2aa7851 + 79632df commit 5276f00

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/Resources/ResourceManager/ResourceManager.format.ps1xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,10 @@
437437
<Label>ResourceId</Label>
438438
<PropertyName>Id</PropertyName>
439439
</ListItem>
440+
<ListItem>
441+
<Label>Tags</Label>
442+
<PropertyName>TagsTable</PropertyName>
443+
</ListItem>
440444
</ListItems>
441445
</ListEntry>
442446
</ListEntries>

src/Resources/ResourceManager/SdkModels/Resources/PSResource.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Resources;
1717
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions;
1818
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkExtensions;
19+
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
1920
using Microsoft.Azure.Management.ResourceManager.Models;
2021
using Newtonsoft.Json.Linq;
2122
using System;
@@ -63,6 +64,11 @@ public class PSResource
6364

6465
public IDictionary<string, string> Tags { get; set; }
6566

67+
public string TagsTable
68+
{
69+
get { return ResourcesExtensions.ConstructTagsTable(TagsConversionHelper.CreateTagHashtable(Tags)); }
70+
}
71+
6672
public string SubscriptionId { get; set; }
6773

6874
public DateTime? CreatedTime { get; set; }

src/Resources/Resources/help/Get-AzResource.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ ResourceGroupName : testRG
101101
ResourceType : Microsoft.Compute/virtualMachines
102102
Location : westus
103103
ResourceId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/testVM
104+
Tags :
105+
Name Value
106+
====== ========
107+
Dept IT
108+
Year 2002
109+
Status Approved
104110
```
105111

106112
This command gets all of the resources whose resource name is "testVM".
@@ -142,6 +148,12 @@ ResourceGroupName : testRG
142148
ResourceType : Microsoft.Compute/virtualMachines
143149
Location : westus
144150
ResourceId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/testVM
151+
Tags :
152+
Name Value
153+
====== ========
154+
Dept IT
155+
Year 2002
156+
Status Approved
145157
```
146158

147159
This command gets the resource with the provided resource id, which is a virtual machine called "testVM" in the resource group "testRG".

0 commit comments

Comments
 (0)