Getting Started with exporting data via API

Azure Costs offers direct API access to integrate the processed and aggregated data directly in 3rd party applications like Qlick or Tableau. This option allows customers on an enterprise plan or higher to render or analyse the Azure Costs data in existing BI solutions. 

Exporting data via API is very simple just follow the steps bellow:

  1. Register an application as trustee to control which data can be access from the 3rd party application in the team management view:




  2. The application contains a client_id and a client_secret which can be used for the oAuth2 client credentials flow. Just issue a new security token at least every hour from the Azure Costs STS. We recommend to issue a token when ever you start a new transaction to ensure that permission changes are affective. 
    curl -X POST -d "client_id={{YOUR CLIENT ID}}&client_secret={{YOUR CLIENT SECERT}}&grant_type=client_credentials" https://azure-costs.com/sts/issue/oauth/token

  3. Export the required report from the export api which returns the data in JSON format. Every single object describes one service including the quantity, costs and other meta information. The required teamId, contract number can be extracted from the URL of the Azure Costs dashboard:
    curl -H "Authorization: Bearer {{ISSUED TOKEN}}" https:/api.azure-costs.com/api/v1/teams/{{TEAMID}}/contracts/{{CONTRACTID}}/reports/{{YEAR}}-{{MONTH}}/export?cache={{DATE-OF-THE-DAY}}

Exporting data as CSP from a customer

Cloud Solution Provider who signed up in Azure Costs are able to export the data of a specific customer they are managing in their Cloud Solution Provider profile. This process requires a token update request which injects the permissions to access a customer teams data. Just update the token by re-issuing an updated token with the following call: 
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer {{ISSUED TOKEN IN STEP 1}}" -d '{"grant_type":"update_token", "delegate": "{{TEAMID OF CUSTOMER}}"}' https://azure-costs.com/sts/issue/oauth/token
The newly generated token needs to be used in step 3 for authorisation as described above. 



Feedback and Knowledge Base