Lez4
Lez4

Reputation: 55

Azure billing API : Resource RateCard & Resource Usage

I need to monitor our Azure spending for each of our client environments (one subscription, multiple resource group). In my research, I’ve found 2 API that I can use :

For the first one, I can obtain the price of each azure resource, it’s really interesting. But I cannot find a way to know what resource is related to a resource group. I need at least the name of the resource. Is-it liked with the “MeterId” information ?

In the second one, I can obtain the usage of all azure resource. It’s perfect ! But how can I convert the resource usage in price ?

In the new azure portal (portal.azure.com), there is a section in a resource group : the billing part. Billing for resource group

It is exactly the information that I’d like to obtain, using your API. Is it a way ?

Upvotes: 3

Views: 3247

Answers (1)

Moinak Bandyopadhyay
Moinak Bandyopadhyay

Reputation: 126

For your first question, the RateCard API returns the list of the resources available at an Azure offer level (Pay-as-you-go, MSDN,…) and this is not specific to a customer’s subscription, so what you would get back here is the list of ALL the resources that are available for billing under an offer, along with resource metadata and prices, and this won’t have details like resource group that are specific to a customer’s subscription. One more point to note is that the resource metadata fields like Meter Name, Meter Category, Meter SubCategory can give customers a better understanding of what resource they are consuming, but this doesn’t include the instance-specific details resourceURI or resource tags.

As for the second question on the Usage API, this API returns aggregated, unrated Usage. The expectation is for the customer to get the aggregated usage data from the Usage API, then get the public rates from the RateCard API for the customer’s offer, and then do the operation of combining usage with the rate details to come up with a rated estimate.

The steps would look like this:

1) Call Usage API with specific time period and AzureSubID

2) Get the OfferID from the Azure Account Portal (go to account.windowsazure.com, select the subscription that you are interested in, bottom right corner has all the sub details including the 'OfferID' (e.g. MS-AZR-0063P)

3) Query the RateCard API with the OfferID, country, region, currency to get list of all resources available to be sold on that offer along with the associated rates, included quantity, discount etc

4) The common field across these two response would be the MeterID. You would get the usage responses with a unique MeterID which you can use to look up the RAteCard API (also called MeterID in RateCard) to get the exact rates that are applicable for this sub.

We are looking into another improvement to make Azure Usage API queryable by a billing cycle so customers don’t have to query by a date range, and they can just opt to query for a particular billing cycle’s usage data to get an exact snapshot of what they were charged that period, but we don't have a timeline on that yet.

Upvotes: 2

Related Questions