Azure Cost Management API - Actual and Amortized Costs

Melissa Lipinski 1 Reputation point
2022-11-29T23:53:33.53+00:00

Hi,

I am trying to get the costs from the Cost Management/Cost Analysis dashboard for our Azure development subscription.

I have tried the following Microsoft.CostManagement API, but get an error "Invalid query definition, Dataset is invalid or not supplied"
[https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/query?api-version=2022-10-01]

I also tried the following Microsoft.Consumption/usageDetails API and it returns data, but unsure if this is the correct one to match the Cost Management/Cost Analysis.
[https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/usageDetails?api-version=2018-03-31&$expand=properties/additionalProperties&metric=actualcost]

I am using our Azure development {subscriptionid} in the API call within a Data Factory data pipeline and storing the data in Azure SQL DB. I am interested in getting the Actual Costs and Amortized Costs from Azure Cost Management/Cost Analysis at Subscription level.

My goal is to get the costs and provide a breakdown of cost data in Power BI over a period of time.

Thank you.

Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
2,034 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SadiqhAhmed-MSFT 37,686 Reputation points Microsoft Employee
    2022-12-01T07:23:02.8+00:00

    Hi @Melissa Lipinski - Thank you for reaching out to us. Happy to assist!

    I understand trying to get the costs for your Azure development subscription. And also interested in getting the Actual Costs and Amortized Costs at Subscription level. Query API and Usage details API should match. So, you can use both.

    Looking at the error for the Query API, seems like you are not using the right Request body. I suggest you to refer to this article for details - https://learn.microsoft.com/en-us/rest/api/cost-management/query/usage?tabs=HTTP

    Hope this helps!

    ----------------------------------------------------------------------------------------------------------------------

    If the response helped, do "Accept Answer" and up-vote it

    0 comments No comments