Answered by:
How do i get Resource and Resource groups Cost information

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.
- Edited by Shubham Tokalwad Thursday, October 17, 2019 3:26 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" } }
- Proposed as answer by SadiqhAhmed-MSFTMicrosoft employee, Moderator Saturday, October 26, 2019 10:17 AM
- Marked as answer by Shubham Tokalwad Monday, November 4, 2019 1:28 PM
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" } }
- Proposed as answer by SadiqhAhmed-MSFTMicrosoft employee, Moderator Saturday, October 26, 2019 10:17 AM
- Marked as answer by Shubham Tokalwad Monday, November 4, 2019 1:28 PM
-
Hey, Sadiqh. It's resolved thanks for your response. I was stuck from long time. Hearty thank you.
- Marked as answer by Shubham Tokalwad Monday, November 4, 2019 1:28 PM
- Unmarked as answer by Shubham Tokalwad Monday, November 4, 2019 1:28 PM
- Edited by Shubham Tokalwad Monday, November 4, 2019 1:29 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
- Edited by Shubham Tokalwad Monday, November 4, 2019 1:52 PM
-
-