none
Which API to use for calculating consumption cost? RRS feed

  • Question

  • Hi everyone,

    We are looking for a way to programmatically get Azure consumption data and cost for an undefined number of tenants. We don't control these tenants or know what type of subscription they are on.

    The Azure Consumption API tells us exactly what we need in theory, and testing it with our own tenant it works perfectly.

    However, the documentation states that only Enterprise and Web Direct Customers are supported. The Az.Billing Powershell module uses the same API and its documentation does not mention this restriction at all. As stated earlier, it works fine for our own tenant, which is on a Microsoft Partner Network subscription.

    Is it safe to assume that it now works for everyone? Or if not, is there any other API we should use that is guaranteed to work for all Azure Cloud subscriptions? Before we can continue, we need to make sure we'll be able to help most of our tenants.

    One final question: we also had a look at the Azure Usage and Ratecard API. To grab the correct Ratecard, we need to know the tenants/subscription Offer ID. It does not seem possible to look this up via an API. When we tried to calculate the cost for our own subscription, we always end up with a difference of a few cents. Are there any examples that explain how to correctly calculate this?

    Thanks for your help.

    Best regards,
    Steven




    • Edited by Steven Rombauts Tuesday, October 1, 2019 2:22 PM Improve subject
    Tuesday, October 1, 2019 1:16 PM

All replies

  • If you are MPN and assuming that you could pull customer data that can't happen, it would be a privacy issue.
    If you are just MPN partners and have your partner ID updated in customers subscription and expecting to have access to customers data, ​that would not be possible

    If you are direct partners or indirect providers you should be able to pull the details using partner center API: https://docs.microsoft.com/en-us/partner-center/develop/get-a-subscriptions-resource-usage-information
    As in this case you have billing relationship with Microsoft.

    For the rate card question:
    Partner rate card has some discounts. Depending on how their calculations are rounded, there will be some cents off here and there.
    Partner needs to know the offer for their customer subscription to get the respective rate card. Since offers don’t change, you could cache the offer ID for each subscription. I am not familiar with an API that returns the offerId.
    Friday, October 4, 2019 1:44 PM
    Moderator