获取客户所有订阅的使用情况摘要

适用于:合作伙伴中心 | Microsoft Cloud for US Government 合作伙伴中心

可以使用 CustomerUsageSummary 资源在当前计费周期内获取客户对特定 Azure 服务或资源的使用情况。

注意

通常,24 小时后,通过 API 或合作伙伴中心门户提供每日评分的未计费使用情况数据。 根据你的位置和计量报告使用情况,可能会发生额外的延迟。

有时,你可能看不到从本月初开始的最新未计费使用情况数据,直到上一个月的计费使用情况数据交付。 这是为了确保计费的使用情况数据在 SLA 中高效传递。 收到计费使用情况数据后,可以从本月初开始检索所有更新的未计费使用情况数据。

先决条件

  • 合作伙伴中心身份验证中所述的凭据。 此方案只支持使用应用凭据和用户凭据进行身份验证。

  • 客户 ID (customer-tenant-id)。 如果不知道客户的 ID,可以通过选择“客户”工作区,然后从客户列表中选择客户,然后选择“帐户”,在合作伙伴中心查找该 ID。 在客户的“帐户”页上,在“客户帐户信息”部分查找 Microsoft ID Microsoft ID 与客户 ID (customer-tenant-id) 相同。

C#

若要获取客户所有订阅的使用情况摘要,请执行以下操作:

  1. 使用 IAggregatePartner.Customers 集合调用 ById() 方法。

  2. 调用 UsageSummary 属性,后跟 Get()GetAsync() 方法:

    // IAggregatePartner partnerOperations;
    // var selectedCustomerId as string;
    
    var usageSummary = partnerOperations.Customers.ById(selectedCustomerId).UsageSummary.Get();
    

有关示例,请参阅以下内容:

REST 请求

请求语法

方法 请求 URI
GET {baseURL}/v1/customers/{customer-tenant-id}/usagesummary HTTP/1.1

URI 参数

下表列出了获取客户的评分使用情况信息的所需查询参数。

名称 类型​​ 必需 说明
customer-tenant-id guid Y 对应于客户的 GUID。

请求标头

有关详细信息,请参阅合作伙伴中心 REST 标头

请求正文

无。

请求示例

GET https://api.partnercenter.microsoft.com/v1/customers/{customer-tenant-id}/usagesummary HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: e128c8e2-4c33-4940-a3e2-2e59b0abdc67
MS-CorrelationId: 47c36033-af5d-4457-80a4-512c1626fac4

REST 响应

如果成功,此方法在响应正文中返回 CustomerUsageSummary 资源。

响应的成功和错误代码

每个响应都带有一个 HTTP 状态代码,用于指示成功或失败以及其他调试信息。 请使用网络跟踪工具来读取此代码、错误类型和其他参数。 有关完整列表,请参阅 错误代码

Microsoft Azure 的响应示例(MS-AZR-0145P) 订阅

在此示例中,客户购买了 145P Azure PayG 产品/服务。

对于具有 Microsoft Azure(MS-AZR-0145P)订阅的客户,不会更改 API 响应。

HTTP/1.1 200 OK
Content-Length: 1120
Content-Type: application/json
MS-CorrelationId: 47c36033-af5d-4457-80a4-512c1626fac4
MS-RequestId: e128c8e2-4c33-4940-a3e2-2e59b0abdc67
Date: Tue, 17 Sep 2019 20:31:45 GMT

{
    "budget":{
        "ammount":300.000000,
        "attributes":{
            "objectType":"SpendingBudget"
        }
    },
    "id":"65726577-C208-40FD-9735-8C85AC9CAC68",
    "name":"600 test",
    "billingStartDate":"2016-02-06T00:00:00-08:00",
    "billingEndDate":"2016-03-05T00:00:00-08:00",
    "totalCost":0.0,
    "currencyLocale":"en-US",
    "lastModifiedDate":"2016-02-26T09:42:54.5130558+00:00",
    "links":{
        "self":{
            "uri":"/customers/{customer-tenant-id}/usagesummary",
            "method":"GET",
            "headers":[]
        }
    },
    "attributes":{
        "objectType":"CustomerUsageSummary"
    }
}

Azure 计划的响应示例

在此示例中,客户购买了 Azure 计划。

对于具有 Azure 计划的客户,API 响应有以下更改:

  • currencyLocale 替换为 currencyCode
  • usdTotalCost 是一个新字段
HTTP/1.1 200 OK
Content-Length: 1120
Content-Type: application/json
MS-CorrelationId: 47c36033-af5d-4457-80a4-512c1626fac4
MS-RequestId: e128c8e2-4c33-4940-a3e2-2e59b0abdc67
Date: Tue, 17 Sep 2019 20:31:45 GMT

{
    "budget": {
        "amount": 97,
        "attributes": {
            "objectType": "SpendingBudget"
        }
    },
    "resourceId": "44908a11-641b-4c53-b7fc-0f2bfca8a581",
    "resourceName": "Modern Azure Customer UK",
    "billingStartDate": "2019-09-01T00:00:00+00:00",
    "billingEndDate": "2019-10-01T00:00:00+00:00",
    "totalCost": 28.82860766744404945074,
    "currencyCode": "GBP",
    "usdTotalCost": 35.23000000000000362337,
    "lastModifiedDate": "2019-09-18T17:09:26.16+00:00",
    "attributes": {
        "objectType": "CustomerUsageSummary"
    }
}