你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

从消耗使用情况详细信息 API 迁移

本文讨论如何从消耗使用情况详细信息 API 迁离。 消耗使用情况详细信息 API 已弃用。 该 API 的关闭日期仍有待确定。 建议尽快从该 API 迁离。

迁移目标

在选择适合你工作负载的解决方案之前,请阅读选择成本详细信息解决方案一文。 一般情况下,如果要持续引入数据或每月使用情况详细信息数据集较大,则建议使用导出。 有关详细信息,请参阅引入使用情况详细信息数据

如果使用情况详细信息数据集较小或场景不满足导出的条件,请考虑改用成本详细信息报告。 有关详细信息,请参阅按需获取小型成本数据集

注意

成本详细信息报告仅适用于具有企业协议或 Microsoft 客户协议的客户。 如果你有 MSDN、即用即付或 Visual Studio 订阅,则可以迁移到导出或使用消耗使用情况详细信息 API 继续。

迁移优点

与耗使用情况详细信息 API 相比,新解决方案提供了许多优势。 摘要如下:

  • 单个数据集用于所有使用情况详细信息 - Azure 和 Azure 市场使用情况详细信息已合并为一个数据集。 该数据集减少了查看所有费用需要调用的 API 数。
  • 可伸缩性 - 市场 API 已弃用,因为它提升的调用模式无法随着 Azure 使用量的增加而缩放。 随着将更多资源部署到云中,使用情况详细信息数据集可能会变得非常大。 市场 API 是一个分页同步 API,因此它没有经过优化,无法通过网络高效可靠地有效传输大量数据。 “导出”和成本详细信息 API 是异步的。 它们提供可通过网络直接下载的 CSV 文件。
  • API 改进 - 导出和成本详细信息 API 是 Azure 支持发展的解决方案。 所有新功能都将集成到这些解决方案中。
  • 架构一致性 - 成本详细信息 API 和导出可为文件提供匹配字段 os,你可以根据方案将其从一个解决方案迁移到另一个解决方案。
  • 成本分配集成 - 使用“导出”或“成本详细信息”API 的企业协议客户和 Microsoft 客户协议客户可以查看与其已配置的成本分配规则相关的费用。 有关成本分配的详细信息,请参阅分配成本

字段差异

下表汇总了“消耗使用情况详细信息”API 和“导出”/“成本详细信息”API 之间的字段差异。 “导出”和“成本详细信息”API 提供 CSV 文件下载,而不是消耗 API 提供的分页 JSON 响应。

企业协议字段映射

使用“消耗使用情况详细信息”API 的企业协议客户具有类型 legacy 的使用情况详细信息记录。 下面显示了旧式使用情况详细信息记录。 由于所有企业协议客户都会使用基础计费系统,因此他们都有此类型的记录。

{  

  "value": [  

      {  

          "id": "{id}", 

          "name": "{name}",  

          "type": "Microsoft.Consumption/usageDetails",  

          "kind": "legacy",  

          "tags": {  

               "env": "newcrp",  

               "dev": "tools"  

          },  

          "properties": {  

…... 

      } 

} 

使用情况详细信息 - 列表 - REST API(Azure 消耗)中显示了完整的旧式使用情况详细信息记录示例

下表提供了旧字段和新字段之间的映射。 “导出”和“成本详细信息”API 生成的 CSV 文件中提供了新属性。 若要了解有关字段的详细信息,请参阅了解使用情况详细信息字段

粗体属性名称保持不变。

旧属性 新属性
accountName AccountName
AccountOwnerId AccountOwnerId
additionalInfo AdditionalInfo
AvailabilityZone AvailabilityZone
billingAccountId BillingAccountId
billingAccountName BillingAccountName
billingCurrency BillingCurrencyCode
billingPeriodEndDate BillingPeriodEndDate
billingPeriodStartDate BillingPeriodStartDate
billingProfileId BillingProfileId
billingProfileName BillingProfileName
chargeType ChargeType
consumedService ConsumedService
cost CostInBillingCurrency
costCenter CostCenter
date 日期
effectivePrice EffectivePrice
频率 频率
invoiceSection InvoiceSectionName
InvoiceSectionId InvoiceSectionId
isAzureCreditEligible IsAzureCreditEligible
meterCategory MeterCategory
meterId 计量 ID
meterName MeterName
MeterRegion MeterRegion
meterSubCategory MeterSubCategory
offerId OfferId
partNumber PartNumber
PayGPrice PayGPrice
PlanName PlanName
PricingModel PricingModel
product ProductName
ProductOrderId ProductOrderId
ProductOrderName ProductOrderName
PublisherName PublisherName
PublisherType PublisherType
quantity 数量
ReservationId 预订 ID
ReservationName ReservationName
resourceGroup ResourceGroup
ResourceId ResourceId
resourceLocation ResourceLocation
resourceName ResourceName
serviceFamily ServiceFamily
ServiceInfo1 ServiceInfo1
ServiceInfo2 ServiceInfo2
subscriptionId SubscriptionId
subscriptionName SubscriptionName
标记 标记
条款 术语
unitOfMeasure UnitOfMeasure
unitPrice UnitPrice
CostAllocationRuleName CostAllocationRuleName

Microsoft 客户协议字段映射

使用“消耗使用情况详细信息”API 的 Microsoft 客户协议客户具有类型 modern 的使用情况详细信息记录。 下面显示了新式使用情况详细信息记录。 由于所有 Microsoft 客户协议客户都会使用基础计费系统,因此他们都有此类型的记录。

{  

  "value": [  

      {  

          "id": "{id}", 

          "name": "{name}",  

          "type": "Microsoft.Consumption/usageDetails",  

          "kind": "modern",  

          "tags": {  

               "env": "newcrp",  

               "dev": "tools"  

          },  

          "properties": {  

…... 

      } 

} 

使用情况详细信息 - 列表 - REST API(Azure 消耗)中显示了完整的旧式使用情况详细信息记录示例

下表显示了旧字段和新字段之间的映射。 “导出”和“成本详细信息”API 生成的 CSV 文件中提供了新属性。 由于解决方案之间的差异而需要映射的字段以粗体文本显示。

有关详细信息,请参阅了解使用情况详细信息字段

旧属性 新属性
invoiceId invoiceId
previousInvoiceId previousInvoiceId
billingAccountId billingAccountId
billingAccountName billingAccountName
billingProfileId billingProfileId
billingProfileName billingProfileName
invoiceSectionId invoiceSectionId
invoiceSectionName invoiceSectionName
partnerTenantId partnerTenantId
partnerName partnerName
resellerName resellerName
resellerMpnId resellerMpnId
customerTenantId customerTenantId
customerName customerName
costCenter costCenter
billingPeriodEndDate billingPeriodEndDate
billingPeriodStartDate billingPeriodStartDate
servicePeriodEndDate servicePeriodEndDate
servicePeriodStartDate servicePeriodStartDate
date date
serviceFamily serviceFamily
productOrderId productOrderId
productOrderName productOrderName
consumedService consumedService
meterId meterId
meterName meterName
meterCategory meterCategory
meterSubCategory meterSubCategory
meterRegion meterRegion
productIdentifier ProductId
product ProductName
subscriptionGuid SubscriptionId
subscriptionName subscriptionName
publisherType publisherType
publisherId publisherId
publisherName publisherName
resourceGroup resourceGroupName
INSTANCENAME ResourceId
resourceLocationNormalized location
resourceLocation location
effectivePrice effectivePrice
quantity quantity
unitOfMeasure unitOfMeasure
chargeType chargeType
billingCurrencyCode billingCurrency
pricingCurrencyCode pricingCurrency
costInBillingCurrency costInBillingCurrency
costInPricingCurrency costInPricingCurrency
costInUsd costInUsd
paygCostInBillingCurrency paygCostInBillingCurrency
paygCostInUSD paygCostInUsd
exchangeRatePricingToBilling exchangeRatePricingToBilling
exchangeRateDate exchangeRateDate
isAzureCreditEligible isAzureCreditEligible
serviceInfo1 serviceInfo1
serviceInfo2 serviceInfo2
additionalInfo additionalInfo
标记 标记
partnerEarnedCreditRate partnerEarnedCreditRate
partnerEarnedCreditApplied partnerEarnedCreditApplied
marketPrice PayGPrice
频率 频率
关键词 关键词
reservationId reservationId
reservationName reservationName
pricingModel pricingModel
unitPrice unitPrice
exchangeRatePricingToBilling exchangeRatePricingToBilling