Authentication for fetching Cost Analysis data

Lalit 1 Reputation point
2023-01-09T10:58:23.65+00:00

Hello,
I am trying to fetch Cost Analysis data via REST API, however facing issues with the Authentication.
https://learn.microsoft.com/en-us/rest/api/cost-management/exports/list?source=recommendations&tabs=HTTP#exportsgetbybillingaccount
Can anyone help me to set up the auth process. Currently I am manually downloading csv files from the portal.

Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
3,577 questions
Windows for business Windows Client for IT Pros Directory services Active Directory
{count} votes

2 answers

Sort by: Most helpful
  1. darsha-MSFT 101 Reputation points Microsoft Employee
    2023-01-10T07:05:46.517+00:00

    Hello @Lalit ,

    As this REST API https://learn.microsoft.com/en-us/rest/api/cost-management/exports/list?source=recommendations&tabs=HTTP#exportsgetbybillingaccount is scoped at billing account, you will require at least the reader role on the billing account to run this API at your billing account scope.

    If you are using the legacy Enterprise Agreement Billing Account, you will have to contact one of the EA Administrator to grant you the role at the EA Billing Account scope. More information can be found here: https://learn.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles and https://learn.microsoft.com/en-us/azure/cost-management-billing/costs/assign-access-acm-data#enterprise-administrator-role.

    If you are using the Microsoft Customer Agreement (MCA) billing account then you will have to contact one of the MCA billing account owner to grant you the role at the MCA Billing Account scope. More information can be found here: https://learn.microsoft.com/en-us/azure/cost-management-billing/manage/understand-mca-roles. I hope this helps.


    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    0 comments No comments

  2. dkrishnaveni-MSFT 1,961 Reputation points Microsoft Employee
    2023-01-10T13:27:57.973+00:00

    Hello,

    Depending upon the offer type MCA/EA you must have billing role access to gain access to view cost related data.

    Furthermore, in case of EA or MCA in addition to appropriate role, existing partner admin/EA admin must enable the cost view for granted user to view the cost data.

    EA admin enable cost view: https://learn.microsoft.com/en-us/azure/cost-management-billing/costs/assign-access-acm-data#enable-access-to-costs-in-the-azure-portal

    MCA enable cost view: https://learn.microsoft.com/en-us/azure/cost-management-billing/costs/get-started-partners#enable-the-policy-to-view-azure-usage-charges

    Hope this helps.

    Regards Divya.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.