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

使用 Azure 计费 API 以编程方式洞察 Azure 用量Use Azure Billing APIs to programmatically get insight into your Azure usage

使用 Azure 计费 API 将用量和资源数据提取到偏好的数据分析工具。Use Azure Billing APIs to pull usage and resource data into your preferred data analysis tools. Azure 资源用量和 RateCard API 可以帮助你准确预测及管理成本。The Azure Resource Usage and RateCard APIs can help you accurately predict and manage your costs. 这些 API 作为资源提供程序实现,属于 Azure 资源管理器公开的 API 系列。The APIs are implemented as a Resource Provider and part of the family of APIs exposed by the Azure Resource Manager.

Azure 发票下载 API(预览版)Azure Invoice Download API (Preview)

完成选择加入后,请使用发票 API 预览版下载发票。Once the opt-in has been complete, download invoices using the preview version of Invoice API. 具体功能包括:The features include:

  • Azure 基于角色的访问控制 - 在 Azure 门户上或通过 Azure PowerShell cmdlet 配置访问策略,指定哪些用户或应用程序有权访问订阅的用量数据。Azure Role-based Access Control - Configure access policies on the Azure portal or through Azure PowerShell cmdlets to specify which users or applications can get access to the subscription’s usage data. 调用方必须使用标准 Azure Active Directory 令牌进行身份验证。Callers must use standard Azure Active Directory tokens for authentication. 将调用方添加到计费读取者、读取者、所有者或参与者角色,以访问特定 Azure 订阅的用量数据。Add the caller to either the Billing Reader, Reader, Owner, or Contributor role to get access to the usage data for a specific Azure subscription.
  • 日期筛选 - 使用 $filter 参数,在发票周期结束日期前按倒序顺序获取所有发票。Date Filtering - Use the $filter parameter to get all the invoices in reverse chronological order by the invoice period end date.

备注

此功能在初始预览版中推出,可能需进行无法向后兼容的更改。This feature is in first version of preview and may be subject to backward-incompatible changes. 目前,它不适用于某些订阅套餐(不支持 EA、CSP、AIO)和 Azure Germany。Currently, it's not available for certain subscription offers (EA, CSP, AIO not supported) and Azure Germany.

Azure 资源使用状况 API(预览)Azure Resource Usage API (Preview)

使用 Azure 资源用量 API 获取预估的 Azure 耗用数据量。Use the Azure Resource Usage API to get your estimated Azure consumption data. 该 API 包括:The API includes:

  • Azure 基于角色的访问控制 - 在 Azure 门户上或通过 Azure PowerShell cmdlet 配置访问策略,指定哪些用户或应用程序有权访问订阅的用量数据。Azure Role-based Access Control - Configure access policies on the Azure portal or through Azure PowerShell cmdlets to specify which users or applications can get access to the subscription’s usage data. 调用方必须使用标准 Azure Active Directory 令牌进行身份验证。Callers must use standard Azure Active Directory tokens for authentication. 将调用方添加到计费读取者、读取者、所有者或参与者角色,以访问特定 Azure 订阅的用量数据。Add the caller to either the Billing Reader, Reader, Owner, or Contributor role to get access to the usage data for a specific Azure subscription.
  • 每小时或每日聚合 - 调用方可以指定 Azure 使用状况数据是以每小时存储桶为单位,还是以每日存储桶为单位。Hourly or Daily Aggregations - Callers can specify whether they want their Azure usage data in hourly buckets or daily buckets. 默认值为每日聚合。The default is daily.
  • 实例元数据(包括资源标记)- 获取实例级详细信息,例如完全限定的资源 URI (/subscriptions/{subscription-id}/..),以及资源组信息和资源标记。Instance metadata (includes resource tags) – Get instance-level detail like the fully qualified resource uri (/subscriptions/{subscription-id}/..), the resource group information, and resource tags. 对于交叉费用等用例,此元数据可帮助你明确以编程方式按标记分配使用状况。This metadata helps you deterministically and programmatically allocate usage by the tags, for use-cases like cross-charging.
  • 资源元数据 - 资源详细信息(如测定仪名称、测定仪类别、测定仪子类别、计价单位和区域)让调用方更好地了解消耗量。Resource metadata - Resource details such as the meter name, meter category, meter sub category, unit, and region give the caller a better understanding of what was consumed. 此外,我们还将致力于跨 Azure 门户、Azure 使用状况 CSV、EA 计费 CSV 和其他面向公众体验的情况下保持资源元数据术语的一致性,从而让你能够在不同体验间关联数据。We're also working to align resource metadata terminology across the Azure portal, Azure usage CSV, EA billing CSV, and other public-facing experiences, to let you correlate data across experiences.
  • 不同产品类型的用量 - 提供产品类型的用量数据,例如即用即付、MSDN、货币承诺、货币信用额和 EA(CSP 除外)。Usage for different offer types – Usage data is available for offer types like Pay-as-you-go, MSDN, Monetary commitment, Monetary credit, and EA, except CSP.

Azure 资源价目表 API(预览)Azure Resource RateCard API (Preview)

使用 Azure 资源 RateCard API 获取可用 Azure 资源的列表,以及每个资源的估计定价信息。Use the Azure Resource RateCard API to get the list of available Azure resources and estimated pricing information for each. 该 API 包括:The API includes:

  • Azure 基于角色的访问控制 - 在 Azure 门户上或通过 Azure PowerShell cmdlet 配置访问策略,指定哪些用户或应用程序有权访问 RateCard 数据。Azure Role-based Access Control - Configure your access policies on the Azure portal or through Azure PowerShell cmdlets to specify which users or applications can get access to the RateCard data. 调用方必须使用标准 Azure Active Directory 令牌进行身份验证。Callers must use standard Azure Active Directory tokens for authentication. 将调用方添加到读取者、所有者或参与者角色,以访问特定 Azure 订阅的用量数据。Add the caller to either the Reader, Owner, or Contributor role to get access to the usage data for a particular Azure subscription.
  • 支持即用即付、MSDN、货币承诺和货币信用额产品(不支持 EA 和 CSP- 此 API 提供 Azure 产品级费率信息。Support for Pay-as-you-go, MSDN, Monetary commitment, and Monetary credit offers (EA and CSP not supported) - This API provides Azure offer-level rate information. 此 API 的调用方必须传入产品/服务信息,才能获取资源详细信息和费率。The caller of this API must pass in the offer information to get resource details and rates. 由于 EA 产品按注册自定义费率,因此我们暂时无法提供 EA 费率。We're currently unable to provide EA rates because EA offers have customized rates per enrollment.

方案Scenarios

使用状况和价目表 API 组合可以实现下面一些方案:Here are some of the scenarios that are made possible with the combination of the Usage and the RateCard APIs:

  • Azure 月支出 - 将用量与 RateCard API 结合使用可以深入了解云的月支出。Azure spend during the month - Use the combination of the Usage and RateCard APIs to get better insights into your cloud spend during the month. 可以分析用量和估计费用的每小时和每日存储桶。You can analyze the hourly and daily buckets of usage and charge estimates.
  • 设置警报 - 可将用量和 RateCard API 结合使用,估计云消耗量和费用,从而设置基于资源或资金的警报。Set up alerts – Use the Usage and the RateCard APIs to get estimated cloud consumption and charges, and set up resource-based or monetary-based alerts.
  • 预测帐单 - 可以估计消耗量和云支出,应用机器学习算法来预测计费周期结束时的帐单。Predict bill – Get your estimated consumption and cloud spend, and apply machine learning algorithms to predict what the bill would be at the end of the billing cycle.
  • 消耗费用分析 - 如果要将工作负荷转移到 Azure,可以使用 RateCard API 来预测帐单(通过提供的所需用量数据)。Pre-consumption cost analysis – Use the RateCard API to predict how much your bill would be for your expected usage when you move your workloads to Azure. 如果在其他云或私有云中拥有现有的工作负荷,则还可以将用量与 Azure 费率进行映射,以便更好地估计 Azure 支出。If you have existing workloads in other clouds or private clouds, you can also map your usage with the Azure rates to get a better estimate of Azure spend. 通过这种估计可以根据产品生成透视图,在不同的产品类型(不仅仅局限于即用即付,还包括货币承诺和货币信用额)之间的对比和对照。This estimate gives you the ability to pivot on offer, and compare and contrast between the different offer types beyond Pay-As-You-Go, like Monetary commitment and Monetary credit. 此外,API 还能够按区域查看费用差异,使你能够做假设性成本分析,帮助做出部署决策。The API also gives you the ability to see cost differences by region and allows you to do a what-if cost analysis to help you make deployment decisions.
  • 假设分析 -What-if analysis -

    • 可以确定在其他区域或 Azure 资源的其他配置上运行工作负荷是否会更具成本效益。You can determine whether it is more cost-effective to run workloads in another region, or on another configuration of the Azure resource. Azure 资源费用根据所用的 Azure 区域而异。Azure resource costs may differ based on the Azure region you're using.
    • 还可以确定其他 Azure 套餐类型是否提供更优惠的 Azure 资源费率。You can also determine if another Azure offer type gives a better rate on an Azure resource.

合作伙伴解决方案Partner solutions

Cloud Cruiser 和 Microsoft Azure 计费 API 集成介绍了 Cloud Cruiser 的 Express for Azure Pack 如何直接从 Windows Azure Pack (WAP) 门户运行。Cloud Cruiser and Microsoft Azure Billing API Integration describes how Cloud Cruiser's Express for Azure Pack works directly from the Windows Azure Pack (WAP) portal. 可以顺畅地在一个用户界面中管理 Microsoft Azure 私有云或托管公有云的运营和财务方面。You can seamlessly manage both the operational and financial aspects of the Microsoft Azure private or hosted public cloud from a single user interface.

后续步骤Next steps