《Windows Azure Platform 系列文章目录》
本文介绍的是海外版的Azure Global服务,因为跨境内境外网络,访问速度会比较慢
在开始使用Azure Billing API之前,我们需要准备:
1.登录https://portal.azure.com,拿到Enrollment Number

2.获取Azure Billing API Key。如下图:

3.有关Azure海外的Billing API,请参考:https://docs.microsoft.com/en-us/azure/billing/billing-enterprise-api
这里简单介绍2个API:
(1)查看账单使用量摘要
(2)查看账单高级报告下载
一.查看账单使用量摘要:
1.REST API
| Method | Request URL |
| Get | https://consumption.azure.com/v3/enrollments/{enrollmentNumber}/balancesummary |
| 举例说明 | https://consumption.azure.com/v3/enrollments/8608480/balancesummary |
2.Request Header
| Request Header Key | Value |
| Authorization | bearer {API Key} |
3.返回结果

返回结果的字段说明:
| 字段名 | 字段说明 |
| id | |
| billingPeriodId | 计费周期 |
| currencyCode | 货币单位 |
| beginningBalance | 初期余额 |
| endingBalance | 期末余额 |
| newPurchases | 新购买 |
| adjustments | 调整 |
| utilized | 使用量 (从余额中扣除) |
| serviceOverage | 服务超额 |
| chargesBilledSeparately | 单独计费的费用 |
| totalOverage | 总超额 |
| totalUsage | 总使用量 (承诺使用量+超额) |
| azureMarketplaceServiceCharges | Azure应用市场服务使用量 |
| newPurchasesDetails | 新购买 |
| adjustmentDetails | 调整详细信详细信息 |
| billingPeriodStart | 计费周期开始时间 |
| billingPeriodEnd | 计费周期结束时间 |
| balanceDeduct | 余额扣除 |
二.查看账单高级报告下载
1.REST API
| Method | Request URL |
| Get | https://consumption.azure.com/v3/enrollments/{enrollmentNumber}/usagedetails/download?billingPeriod={billingPeriod} |
| 举例说明 | https://consumption.azure.com/v3/enrollments/8608480/usagedetails/download?startTime=2019-07-20&endTime=2019-08-10 |
2.Request Header
| Request Header Key | Value |
| Authorization | bearer {API Key} |
3.返回结果

返回结果的字段说明:
| 字段名 | 说明 |
| AccountId | 创建该订阅的ID |
| AccountName | 账户名称 |
| AccountOwnerEmail | 账户所有者邮箱 |
| AdditionalInfo | 附加信息 |
| ConsumedQuantity | 已消耗的数量 |
| ConsumedService | 消耗的服务类型 |
| ConsumedServiceId | 消耗的服务ID |
| Cost | 费用 |
| CostCenter | 资源所属的Cost Center成本中心 ,成本中心只在EA Portal里面定义 |
| Date | 表示该计费资源的计费时间,比如2019-06-01 |
| DepartmentId | 部门ID |
| DepartmentName | 资源所属的部门,部门只在EA Portal里面定义 |
| InstanceId |
资源的唯一ID 对于ARM资源来说,组件展现的形式如下: /subscriptions/{订阅ID}/resourceGroups/{资源组名称}/providers/Microsoft.Compute/virtualMachines/{虚拟机名称} |
| MeterCategory | 服务的一级类别 |
| MeterId | 类别Id |
| MeterName | 类别名称 |
| MeterRegion | 类别区域 |
| MeterSubCategory | 服务的二级类别 |
| Product | 产品 |
| ProductId | 产品Id |
| ResourceGroup | 资源组 |
| ResourceLocation | 资源组所属区域 |
| ResourceLocationId | 资源组所属区域Id |
| ResourceRate | 每计费单位适用的费率 |
| ServiceAdministratorId | 服务管理员Id |
| ServiceInfo1 | 服务信息1 |
| ServiceInfo2 | 服务信息2 |
| StoreServiceIdentifier | 该字段不经常使用 |
| SubscriptionGuid | 订阅Guid |
| SubscriptionId | 订阅ID |
| SubscriptionName | 订阅的显示名称 |
| Tags | 标签 |
| UnitOfMeasure |
列:已消耗的资源数量的单位 比如虚拟机计算资源,是按照小时来收费的,则该列显示为Hour 对于存储来说,是按照GB来收费的。则该列会显示GB |
| PartNumber | 服务的SKU Number |
| ResourceGuid | 不经常使用 |
| OfferId | 不经常使用 |
| ChargesBilledSeparately | 超出货币承诺的收费 |
| Location | 服务所在数据中心区域 |
| ServiceName | 服务名称 |
| ServiceTier | 服务等级 |

浙公网安备 33010602011771号