Azure / BillingCodeSamples

52 stars 24 forks source link

How to get the cost of a project from the usage quanity & meterRates? #15

Closed jobinar closed 9 years ago

jobinar commented 9 years ago

From the usage API I see that we can get the usage quantity of a resource for a project and the rate for the resource consumption from the rate card API. However, the rate card API, in some cases, has a list of key-value pairs.

For ex, consider the following MeterRates: "MeterRates": { "0": 0.0832, "1024": 0.0819, "51200": 0.0806, "512000": 0.0794, "1024000": 0.0775, "5120000": 0.0775 },

Here, if the usage quantity is, say, 102400; does it mean the cost of using the resource will be 102400 * 0.0784 or (102400 - 1023) * 0.0832 + (102400 - 1023 - 51200) * 0.0819?

moinak3 commented 9 years ago

RateCard follows tiered pricing, which means that if there are multiple tiers for rating a particular resource, each subset of usage in each tier is rated differently.

Let’s take an example for consumed quantity = 250

Let’s assume the rates:

0: 1 200: 0.9 500: 0.8

This means that usage for units 0 – 199 should be rated at 1 per unit, 200 – 499 at 0.9 per unit and 500+ at 0.8 per unit.

Consumed quantity of 250 would be billed at: 510.9 + 199 \ 1 = 244.9

ExSport commented 6 years ago

Hi, can you please clarify if MeterRates tiered pricing is per billing period (month) or how is it counted? Also there is a tiered pricing like 0-199 for 1$ and 200-499 for 0.9$. How to compute consumption of 205 or 199.7 units? For 205 it is ((199*1) + (6*0.9)) or ((199.999999*1) + (5*0.9))? For 199.7 it is ((199*1)+(0.7*0.9)) or (199.7*1)? There is no official info how to deal witch such computation. Thanks!