Open Oechiih opened 5 years ago
@ms-premp Can you take a look at this issue?
Team is investigating.
I got the same issue. I tried the following commands, nothing works:
$tagFilter = "@{'Owner'='FF'}" $tagFilter = "@{'Owner'=FF}" $tagFilter = "@{Owner='FF'}" $tagFilter = "@{Owner=FF}"
$tagFilter = "@{'Owner':'FF'}" $tagFilter = "@{'Owner':FF}" $tagFilter = "@{Owner:'FF'}" $tagFilter = "@{Owner:FF}"
$tagFilter = "'Owner':'FF'" $tagFilter = "'Owner':FF" $tagFilter = "Owner:'FF'" $tagFilter = "Owner:FF"
$tagFilter = "HelloWorld"
Get-AzConsumptionUsageDetail -BillingPeriodName 202007 -Tag $tagFilter
I got the same result for all the examples above.. no difference, i can put anything, same result. My workaround until this issue is fixed is to parse the variable object Tags returned by "Get-AzConsumptionUsageDetail". So all manual
Btw: I think the right syntax in Powershell should be : "@{'Owner'='FF'}" as when you export with Azure portal, the Azure Tags column appears on JSON format
This one appears to have been fixed. please verify and reopen issue as needed. Thank you for the feedback.
Hi @ramaganesan-rg I beg to differ, I tried to get it to work again, trying several options with no luck at all. Even if the issue would have been technically fixed the documentation is still missing. Also it still just returns all resources instead of none when the tag filter is invalid. In my opinion my initially reported issue still stands.
Thanks for chiming in, the team will be looking into it.
From: Jan Oehen notifications@github.com Sent: Friday, October 23, 2020 3:11 AM To: Azure/azure-powershell azure-powershell@noreply.github.com Cc: Rama Ganesan ramagane@microsoft.com; Mention mention@noreply.github.com Subject: Re: [Azure/azure-powershell] Get-AzConsumptionUsageDetail does not honor 'Tag' parameter (#8971)
Hi @ramaganesan-rghttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Framaganesan-rg&data=04%7C01%7Cramagane%40microsoft.com%7C660eb50b798545ee541008d8773bed7f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637390446555857726%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=G3Nk8ITNmT7RztcwvMgtGs8EMkHITzXG8NHdFpiXwek%3D&reserved=0 I beg to differ, I tried to get it to work again, trying several options with no luck at all. Even if the issue would have been technically fixed the documentation is still missing. Also it still just returns all resources instead of none when the tag filter is invalid. In my opinion my initially reported issue still stands.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-powershell%2Fissues%2F8971%23issuecomment-715245012&data=04%7C01%7Cramagane%40microsoft.com%7C660eb50b798545ee541008d8773bed7f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637390446555857726%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=JRfbe6iWouuDv4tZ32X2ryUGIzTR3Mh%2FZBCue4culaA%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAMK4VB4EQXMQJS2E4GYRTDTSMFJC5ANCNFSM4HERLVAA&data=04%7C01%7Cramagane%40microsoft.com%7C660eb50b798545ee541008d8773bed7f%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637390446555867723%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=%2BlUrkvUq6xzk2iopxQDMOQS4J1iEXdkW4CPUd7jHzPc%3D&reserved=0.
I have a workaround:
For example you have: Tag Name: BillingId Tag Value: 123456
The the command to look for the last 30 days consumption would be:
(Get-AzConsumptionUsageDetail -StartDate ([datetime]::Now.AddDays(-30)) -EndDate ([datetime]::Now.AddHours(0))) | Where-Object {$_.Tags -ne $null} | Where-Object {$_.Tags['BillingId'] -eq "123456"}
It seems that the issue is still there. No key:value pairs are respected by the command.
Also, I tried @zmustafa workaround and it failed too with the following error: $.Tags : The term '$.Tags' is not recognized as the name of a cmdlet, function, script file, or operable program.
Am I using the command wrong somehow?
It seems that the issue is still there. No key:value pairs are respected by the command.
Also, I tried @zmustafa workaround and it failed too with the following error: $.Tags : The term '$.Tags' is not recognized as the name of a cmdlet, function, script file, or operable program.
Am I using the command wrong somehow?
Add underscores like this: (Get-AzConsumptionUsageDetail -StartDate ([datetime]::Now.AddDays(-30)) -EndDate ([datetime]::Now.AddHours(0))) | Where-Object {$.Tags -ne $null} | Where-Object {$.Tags['tagname'] -eq "tagvalue"}
@Barzdaz the underscores following the dollar-signs are not visible here on GitHub. After a pipe you need to use "dollar-underscore" to reference the pipeline variable in PowerShell. @zmustafa Your workaround works fine. But still I feel like either the Parameter needs to be "fixed", properly documented or removed from this CMDLet.
It seems that the issue is still there. No key:value pairs are respected by the command.
Also, I tried @zmustafa workaround and it failed too with the following error: $.Tags : The term '$.Tags' is not recognized as the name of a cmdlet, function, script file, or operable program.
Am I using the command wrong somehow?
Updated the original solution with underscores.
I have a workaround:
For example you have: Tag Name: BillingId Tag Value: 123456
The the command to look for the last 30 days consumption would be:
(Get-AzConsumptionUsageDetail -StartDate ([datetime]::Now.AddDays(-30)) -EndDate ([datetime]::Now.AddHours(0))) | Where-Object {$_.Tags -ne $null} | Where-Object {$_.Tags['BillingId'] -eq "123456"}
This one has some disadvantages. It eats memory and cpu if the environment is big enough as it will "get" thousands or even 100thousands of entries, although you might be only searching for 40 entries. So the Tag to work is heavily needed! Especially if you want to handle this in some form of function app, where you want to look at memory usage and cpu usage.
Can someone please reopen this issues? MS Support asked me to ask this here. This problem is not fixed, as the workaround is not ressource-friendly at all and the function for TAGS is just not at all working. Additionally also the Restmethod does not work correctly with tags, as it will only show entries, that have the full tagset delivered, which is nonsense, as nobody might know ALL the tags of the element he wants to find. So at the moment there is only they way to get all data and filter later, which is not sufficient!
Posting on behalf of dev team: Apologies for the delay. The Engineers investigated the issue and found that this issue is due to a bug in our PS SDK. Team has created a backlog item for prioritization in our upcoming sprint planning.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @TiagoCrewGitHubIssues.
Author: | Oechiih |
---|---|
Assignees: | ms-premp |
Labels: | `Consumption`, `Consumption-UsageDetailsandExport`, `Service Attention`, `bug`, `customer-reported` |
Milestone: | - |
Our apologies for the continued delay. We are triaging this will provide an update once we have more information.
Please also look at the query speed when date is limited. It looks to me that querying is not the most effective way for performance.
we still have this in our backlog and have started the design for this. We'll keep this issue updated
we still have this in our backlog and have started the design for this. We'll keep this updated.
@Oechiih Apologies for the late reply. As mentioned by @tujamg, we will update this thread once this issue is addressed.
Description
Related #8876
When using Get-AzConsumptionUsageDetail with the 'Tag' parameter it is still returning all resources. According to documentation the parameter should be a string value. Digging a little deeper, into the REST API documentation I found out it should be a simple key-value pair separated by a colon i.e. 'key:value'. In the source code of Get-AzConsumptionUsageDetail on line 167 I noted how it handled my input. However the API completely ignores my filter and just returns all my resources instead. As we can see the PS module prepares the request with the filter 'properties/tags eq' however the API example is using just 'tags'. I tried both variations in Postman and got mixed results:
Steps to reproduce
Environment data
Module versions
Debug output
Error output
No error only unexpected results.