azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Fix querying through tags on Find-AzureRmResource and Find-AzureRmResourceGroup

Open ravbhatnagar opened this issue 10 years ago • 9 comments

Find-AzureRmResource -ODataQuery "$filter=tagname eq 'DBCheckService'" - this does not work. Currently the workaround is to do the following- Find-AzureRmResource | Where-Object {$.Tags.Name-eq "DBCheckService" -and $.Tags.Value -eq "true"}

Also, for Resource we support tagname and tagvalue but for resource group cmdlet we support tag.

ravbhatnagar avatar Mar 09 '16 22:03 ravbhatnagar

You need to escape the "$" in the query parameter. Like this: -ODataQuery "`$filter=tagName eq 'DBCheckService'".

I'll add a Tag parameter for Find-AzureRmResource.

TianoMS avatar Aug 25 '16 00:08 TianoMS

@TianoMS Please close if the issue is fixed. Otherwise, please assign to the appropriate milestone

markcowl avatar Sep 12 '16 19:09 markcowl

There are 2 issues in this one - first is that querying through OData query didn't work. This one does not need fix as mentioned by Tian above. Second was adding the Tag param to Find-AzureRmResource cmdlet similar to what we have in Find-AzureRmResourceGroup cmdlet. this one needs to be fixed.

ravbhatnagar avatar Sep 23 '16 01:09 ravbhatnagar

Closing as this is tracked through multiple other issues.

ravbhatnagar avatar Nov 10 '16 07:11 ravbhatnagar

@ravbhatnagar Can you link to the other issues you refer to? I currently cannot find any open, and yet this issue still exists (at the API).

for instance, I'm getting:

Invalid $filter 'resourceType eq 'Microsoft.Compute/virtualMachines' and tagName eq 'myTagName' and tagValue eq 'myTagValue'' specified in the query string."

JoeBrockhaus avatar Jan 26 '17 01:01 JoeBrockhaus

@JoeBrockhaus - As noted by @TianoMS in one of the comments above, for the $filter to work in the query,"$" needs to be escaped with `. Please let me know if you still see this issue.

ravbhatnagar avatar Jan 26 '17 01:01 ravbhatnagar

@ravbhatnagar I see. I don't think this is something I have direct control over, as I'm using the ResourceManagementClient from v1.4.0-preview of Microsoft.Azure.Management.ResourceManager.

I just created a bug over there, I'll reference your comment. Thanks.

JoeBrockhaus avatar Jan 26 '17 02:01 JoeBrockhaus

Get-AzureRmResource -ODataQuery "`$filter=tagname eq 'schedule'" -TenantLevel

doesnt work, but this does:

Get-AzureRmResource -ODataQuery "`$filter=tagname eq 'schedule'" 

bug? probably feature, right? :)

4c74356b41 avatar Apr 26 '18 06:04 4c74356b41

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @rthorn17

ghost avatar Aug 14 '19 19:08 ghost