Forum Discussion

akim_no's avatar
akim_no
Helper III
7 months ago
Solved

Azure Cost Management API & Power BI – Permissions, data access, and historical analysis

Hello everyone,

Has anyone already worked with Azure Cost Management to retrieve cost data into Power BI and build monthly analysis reports?

The goal is to historize cost data and analyze trends over time. I have several questions and would really appreciate your feedback or experience:

  • What permissions / roles are required to access Azure Cost Management APIs and retrieve cost data (both at subscription and billing scope)?

  • When calling the API endpoint
    /providers/Microsoft.Billing/billingAccounts/{billingAccountId},
    is this supposed to return all available cost data? In my case, some tables return no data at all (screen 2) , and for others I get Bad Request errors (screen1), so I’m struggling to understand how the API is structured and how it should be queried properly.

  • Do you use the native Azure Cost Management connector in Power BI to query the APIs directly? If so, how does it behave in terms of API calls, refresh frequency, data volume, and historical data limits?

  • I also noticed that it is possible to configure exports from Cost Management + Billing. From an architecture perspective, what is the recommended way to industrialize this process and historize the data? Should this be done through an automated pipeline (Data Factory, Logic Apps, etc.) that stores the data in a Data Lake or Data Warehouse, and then consumed by Power BI?

In short, is the Power BI Cost Management connector sufficient for long-term cost analysis, or is another approach required for a more robust and scalable solution?

Thanks in advance for your help and explanations.

 

 

 

  • Hi akim_no , Thank you for reaching out to the Microsoft Community Forum.

     

    This is a scope and billing-model mismatch, not a misconfiguration in Power BI. Azure Cost Management APIs are strictly scope-bound. You can query either subscription scope or billing account / billing profile scope, but you cannot mix them in a single request. The 404 you see on the CostManagement/query call is caused by an invalid ARM path where subscription scope is effectively nested under a billing account. That endpoint will always fail, even with correct permissions. Separately, several tables exposed under the billing account scope (for example balance or credits) rely on Consumption APIs that are not supported for all billing models (especially MCA), so Power BI shows them in Navigator but they return 404 or empty results at runtime. That  is expected.

     

    Permissions also have to align with scope. Subscriptionlevel cost queries require Cost Management Reader on the subscription. Billing account level queries require Billing Reader or Cost Management Reader at the billing account or billing profile. Having access at one scope does not imply access at the other. Empty Usage details previews usually mean you are connected at a billing scope where usage is not exposed the same way or there is no finalized invoice yet, this is common and not an error.

     

    For architecture, the native Power BI Azure Cost Management connector is fine for exploration and short term analysis, but it is not designed for reliable historization. Microsoft’s supported pattern for long term, scalable cost analytics is Cost Management Exports to storage (ADLS/Blob), optionally processed via Data Factory or similar and then consumed by Power BI. If your goal is monthly trends over years with stable schemas and predictable refresh, exports are the correct and supported solution.

     

    Microsoft Cost Details API now generally available for EA and MCA customers | Microsoft Azure Blog

    Tutorial - Create and manage Cost Management exports - Microsoft Cost Management | Microsoft Learn

    Azure Cost Management connector - Power Query | Microsoft Learn

     

9 Replies

  • I'm a little familiar with this but it's probably just a permissions/endpoint issue.

     

    It would be good to check you have the following permissions:

    • Cost Management Reader (or Contributor)
    • Billing Reader
    • Billing Account Reader (potentially too, but might not be necessary)

    I think the endpoint you are calling returns metadata, not cost data, can you try 

    /subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/query  

    The Azure Cost Management Connector is pretty good link here.

     

    A totally different workaround (depends on your data engineering ability or capability in your team) would be to export the cost data to storage (say a data lake partitioned by date) and query it from there instead.

     

    I'd be interested to know if the permissions or endpoint were the issue. Good luck!

  • This is the documentation I followed to connect to the API, but I’m having issues retrieving data and I’m not sure what I’m missing.

     

  • v-hashadapu's avatar
    v-hashadapu
    Community Support

    Hi akim_no , Thank you for reaching out to the Microsoft Community Forum.

     

    This is a scope and billing-model mismatch, not a misconfiguration in Power BI. Azure Cost Management APIs are strictly scope-bound. You can query either subscription scope or billing account / billing profile scope, but you cannot mix them in a single request. The 404 you see on the CostManagement/query call is caused by an invalid ARM path where subscription scope is effectively nested under a billing account. That endpoint will always fail, even with correct permissions. Separately, several tables exposed under the billing account scope (for example balance or credits) rely on Consumption APIs that are not supported for all billing models (especially MCA), so Power BI shows them in Navigator but they return 404 or empty results at runtime. That  is expected.

     

    Permissions also have to align with scope. Subscriptionlevel cost queries require Cost Management Reader on the subscription. Billing account level queries require Billing Reader or Cost Management Reader at the billing account or billing profile. Having access at one scope does not imply access at the other. Empty Usage details previews usually mean you are connected at a billing scope where usage is not exposed the same way or there is no finalized invoice yet, this is common and not an error.

     

    For architecture, the native Power BI Azure Cost Management connector is fine for exploration and short term analysis, but it is not designed for reliable historization. Microsoft’s supported pattern for long term, scalable cost analytics is Cost Management Exports to storage (ADLS/Blob), optionally processed via Data Factory or similar and then consumed by Power BI. If your goal is monthly trends over years with stable schemas and predictable refresh, exports are the correct and supported solution.

     

    Microsoft Cost Details API now generally available for EA and MCA customers | Microsoft Azure Blog

    Tutorial - Create and manage Cost Management exports - Microsoft Cost Management | Microsoft Learn

    Azure Cost Management connector - Power Query | Microsoft Learn

     

  • v-hashadapu's avatar
    v-hashadapu
    Community Support

    Hi akim_no , hope you are doing great. May we know if your issue is solved or if you are still experiencing difficulties. Please share the details as it will help the community, especially others with similar issues.

  • v-hashadapu's avatar
    v-hashadapu
    Community Support

    Hi akim_no , Hope you're doing okay! May we know if it worked for you, or are you still experiencing difficulties? Let us know — your feedback can really help others in the same situation.