您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

面向企业客户的报告 API 概述Overview of Reporting APIs for Enterprise customers

报告 API 使企业 Azure 客户能够以编程方式将消耗数据和计费数据提取到首选的数据分析工具。The Reporting APIs enable Enterprise Azure customers to programmatically pull consumption and billing data into preferred data analysis tools. 企业客户与 Azure 签订了企业协议 (EA),以达成协商的货币承诺并获取自定义 Azure 资源定价的访问权限。Enterprise customers have signed an Enterprise Agreement (EA) with Azure to make negotiated monetary commitments and gain access to custom pricing for Azure resources.

实现对 API 的数据访问Enabling data access to the API

  • 生成或检索 API 密钥 - 登录到 Enterprise Portal,并导航到“报告”>“下载使用情况”>“API 访问密钥”,生成或检索 API 密钥。Generate or retrieve the API key - Log in to the Enterprise portal, and navigate to Reports > Download Usage > API Access Key to generate or retrieve the API key.
  • 传递 API 密钥 - 需要为每个调用传递 API 密钥,以便进行身份验证和授权。Passing keys in the API - The API key needs to be passed for each call for Authentication and Authorization. 以下属性需要是 HTTP 标头The following property needs to be to the HTTP headers
请求标头密钥Request Header Key Value
授权Authorization 用以下格式指定该值:bearer {API_KEY} Specify the value in this format: bearer {API_KEY}
示例:bearer eyr....09Example: bearer eyr....09

消耗量 APIConsumption APIs

可在此处找到为下面所述的 API 提供的 Swagger 终结点,该终结点可以使用 AutoRestSwagger CodeGen 进行简单的 API 自检并生成客户端 SDK。A Swagger endpoint is available here for the APIs described below which should enable easy introspection of the API and the ability to generate client SDKs using AutoRest or Swagger CodeGen. 2014 年 5 月 1 日开始的数据就是通过此 API 提供的。Data beginning May 1, 2014 is available through this API.

  • 余额和摘要 - 余额和摘要 API 提供关于余额、新购买、Azure 市场服务费用、调整和超额费用信息的每月摘要。Balance and Summary - The Balance and Summary API offers a monthly summary of information on balances, new purchases, Azure Marketplace service charges, adjustments and overage charges.

  • 使用情况详细信息 - 使用情况详细信息 API 提供已耗用量和注册估计费用的日常明细。Usage Details - The Usage Detail API offers a daily breakdown of consumed quantities and estimated charges by an Enrollment. 结果还包括有关实例、计量和部门信息。The result also includes information on instances, meters and departments. 可以按照计费周期或指定的开始日期和结束日期查询 API。The API can be queried by Billing period or by a specified start and end date.

  • 市场应用商店费用 - 市场应用商店费用 API 会返回基于使用情况的市场费用明细(不包括一次性费用),且按指定计费周期的天或开始和结束日期排列。Marketplace Store Charge - The Marketplace Store Charge API returns the usage-based marketplace charges breakdown by day for the specified Billing Period or start and end dates (one time fees are not included).

  • 价目表 - 价目表 API 为给定注册和计费周期的每个计量提供适用的费率。Price Sheet - The Price Sheet API provides the applicable rate for each Meter for the given Enrollment and Billing Period.

  • 保留实例详细信息-保留实例使用情况 API返回的使用情况的保留实例购买。Reserved Instance Details - The Reserved Instance usage API returns the usage of the Reserved Instance purchases. 保留实例费用 API显示所做的计费事务。The Reserved Instance charges API shows the billing transactions made.

数据刷新Data Freshness

在上述所有 API 的响应中将返回 Etag。Etags will be returned in the response of all the above API. Etag 中的更改指示数据已刷新。A change in Etag indicates the data has been refreshed. 在使用相同参数对同一 API 的后续调用中,将使用 http 请求标头中的键“If-None-Match”传递捕获的 Etag。In subsequent calls to the same API using the same parameters, pass the captured Etag with the key “If-None-Match” in the header of http request. 如果没有进一步刷新数据,则响应状态代码将为“NotModified”且不会返回任何数据。The response status code would be "NotModified" if the data has not been refreshed any further and no data will be returned. 只要存在 etag 更改,API 就会返回所需时段内的完整数据集。API will return the full dataset for the required period whenever there is an etag change.

帮助程序 APIHelper APIs

列出计费周期 - 计费周期 API 会以倒序顺序为指定的注册返回具有消耗数据的计费周期列表。List Billing Periods - The Billing Periods API returns a list of billing periods that have consumption data for the specified Enrollment in reverse chronological order. 每个周期都有一个属性指向以下 4 个数据集的 API 路由:BalanceSummary、UsageDetails、Marketplace Charge 和 PriceSheet。Each Period contains a property pointing to the API route for the four sets of data - BalanceSummary, UsageDetails, Marketplace Charges, and Price Sheet.

API 响应代码API Response Codes

响应状态代码Response Status Code MessageMessage 描述Description
200200 OKOK 无错误No error
401401 未授权Unauthorized API 密钥找不到、无效、已过期等。API Key not found, Invalid, Expired etc.
404404 不可用Unavailable 找不到报表终结点Report endpoint not found
400400 错误的请求Bad Request 参数无效 – 日期范围、EA 号等。Invalid params – Date ranges, EA numbers etc.
500500 服务器错误Server Error 处理请求时出现异常错误Unexpected error processing request