none
How do i get Resource and Resource groups Cost information RRS feed

  • Question

  • I am using 

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

    this api to get cost information, In scope i am providing '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}'.

    but, in response i am getting only UsageDate and Currency. How do i get  PreTaxCost and ResourceGroup also.



    Thursday, October 17, 2019 3:25 PM

Answers

  • Here’s a query payload expecting would work for you. Let me know what payload you were trying and what API version you were using. This was tested with the latest version (2019-10-01). 

    {
                   "type": "ActualCost",
                   "dataSet": {
                                  "granularity": "None",
                                  "aggregation": {
                                                 "totalCost": {
                                                                "name": "PreTaxCost",
                                                                "function": "Sum"
                                                 }
                                  },
                                  "grouping": [
                                                 {
                                                                "type": "Dimension",
                                                                "name": "ResourceId"
                                                 },
                                                 {
                                                                "type": "Dimension",
                                                                "name": "ResourceType"
                                                 },
                                                 {
                                                                "type": "Dimension",
                                                                "name": "ResourceLocation"
                                                 },
                                                 {
                                                                "type": "Dimension",
                                                                "name": "ResourceGroupName"
                                                 },
                                                 {
                                                                "type": "Dimension",
                                                                "name": "SubscriptionName"
                                                 }
                                  ],
                                  "include": [
                                                 "Tags"
                                  ]
                   },
                   "timeframe": "Custom",
                   "timePeriod": {
                                  "from": "2019-10-01T00:00:00+00:00",
                                  "to": "2019-10-31T23:59:59+00:00"
                   }
    }
    


    Saturday, October 26, 2019 10:17 AM
    Moderator

All replies

  • Here’s a query payload expecting would work for you. Let me know what payload you were trying and what API version you were using. This was tested with the latest version (2019-10-01). 

    {
                   "type": "ActualCost",
                   "dataSet": {
                                  "granularity": "None",
                                  "aggregation": {
                                                 "totalCost": {
                                                                "name": "PreTaxCost",
                                                                "function": "Sum"
                                                 }
                                  },
                                  "grouping": [
                                                 {
                                                                "type": "Dimension",
                                                                "name": "ResourceId"
                                                 },
                                                 {
                                                                "type": "Dimension",
                                                                "name": "ResourceType"
                                                 },
                                                 {
                                                                "type": "Dimension",
                                                                "name": "ResourceLocation"
                                                 },
                                                 {
                                                                "type": "Dimension",
                                                                "name": "ResourceGroupName"
                                                 },
                                                 {
                                                                "type": "Dimension",
                                                                "name": "SubscriptionName"
                                                 }
                                  ],
                                  "include": [
                                                 "Tags"
                                  ]
                   },
                   "timeframe": "Custom",
                   "timePeriod": {
                                  "from": "2019-10-01T00:00:00+00:00",
                                  "to": "2019-10-31T23:59:59+00:00"
                   }
    }
    


    Saturday, October 26, 2019 10:17 AM
    Moderator
  • Hey, Sadiqh. It's resolved thanks for your response. I was stuck from long time. Hearty thank you.
    Monday, November 4, 2019 1:24 PM
  • Actually, I have other issue related Diagnostics settings. I want accurate API for below data i.e. Resources with Name,Resource Type, Resource Group & Diagnostics status under diagnostics settings. Could you please help with this issue. I have tried few Azure Rest API but i didn't get what i want


    
    Monday, November 4, 2019 1:51 PM
  • I don't think there is an API to get this info.
    Tuesday, November 5, 2019 7:10 AM
    Moderator
  • If there is multiple API then that will be ok. Or if there is another way to get this data then that will be great. waiting for your response

    Thursday, November 7, 2019 5:03 AM