Azure cost management REST API access management at resource group scope not working

Rajesh Nerenki 1 Reputation point
2020-07-30T15:11:01.497+00:00

I'm using the Azure cost management API to read monthly spend. Users are allowed to read the costs of the resource groups for which they have been given "Cost Management Reader" access. The cost management usage REST API seems to have a bug. Even though I've restricted access to specific resource groups, when I run the below POST request at subscription scope, it retrieves the costs for all resource groups. What I noticed is when no access is granted to any resource group, REST API returns a 401 response. But when I give access to even one resource group, then it returns costs for all resource groups. The behavior is not the same in azure portal.

https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/query?api-version=2019-11-01

{
  "type": "Usage",
  "timeframe": "MonthToDate",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}
Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
3,582 questions
{count} votes

2 answers

Sort by: Most helpful
  1. olufemia-MSFT 2,861 Reputation points
    2020-08-08T21:32:34.76+00:00

    Hi anonymous user , apologies for the delay. Thanks to your update, we were able to reproduce this issue and identified the root-cause bug. The feature owner acknowledged that a fix is being planned and we will update this post as soon as the fix is deployed. Thanks again for not only catching this but alerting us to the issue.

    Cheers.


  2. Rajesh Nerenki 1 Reputation point
    2020-09-15T09:01:13.427+00:00

    Hi @olufemia-MSFT , It has been a while now still no update. It appears the fix has introduced a bug rather than resolving it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.