分享方式:


取得客戶的訂用帳戶使用量摘要

適用于:合作夥伴中心 |適用于 Microsoft Cloud for US Government 的合作夥伴中心

您可以使用 SubscriptionUsageSummary 資源來取得客戶的訂用帳戶使用量摘要。 此資源代表目前計費期間內特定 Azure 服務或資源的訂用帳戶使用量摘要。

必要條件

  • 認證,如合作夥伴中心驗證所述。 此案例僅支援使用「應用程式+使用者」認證來進行驗證。

  • 客戶識別碼 (customer-tenant-id)。 如果您不知道客戶的識別碼,您可以選取 [客戶] 工作區,然後從客戶清單中選取客戶,然後從客戶清單中查閱該識別碼。 在客戶的 [帳戶] 頁面上,尋找 [客戶帳戶資訊] 區段中的 [Microsoft 識別碼] 。 Microsoft 識別碼與客戶識別碼 () customer-tenant-id 相同。

  • 訂用帳戶識別碼

C#

若要取得客戶訂用帳戶的訂用帳戶使用量摘要:

  1. 使用 IAggregatePartner.Customers 集合來呼叫 ById () 方法。

  2. 然後呼叫 Subscriptions 屬性和 UsageSummary 屬性。 藉由呼叫 Get () 或 GetAsync () 方法來完成。

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

如需範例,請參閱下列各項:

REST 要求

要求的語法

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

URI 參數

下表列出取得客戶評等使用量資訊所需的查詢參數。

名稱 類型 必要 描述
customer-tenant-id guid Y 對應至客戶的 GUID。
subscription-id guid Y 對應至訂用帳戶識別碼的 GUID。 針對 Azure 方案,這是對應合作夥伴中心訂用帳戶 資源的識別碼,代表 Azure 方案。 針對 Azure 方案訂用帳戶資源,請在此路由中提供 plan-id 作為 subscription-id

要求標頭

如需詳細資訊,請參閱合作夥伴中心 REST 標頭

要求本文

無。

要求範例

GET https://api.partnercenter.microsoft.com/v1/customers/{customer-tenant-id}/subscriptions/{subscription-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 回應

如果成功,這個方法會在回應本文中傳回 SubscriptionUsageSummary 資源。

回應成功和錯誤碼

每個回應都隨附 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

{
    "resourceId": "ABCDEFGH-F347-41B6-B02C-187B1B778A43",
    "id": "ABCDEFGH-F347-41B6-B02C-187B1B778A43",
    "resourceName": "Microsoft Azure",
    "name": "Microsoft Azure",
    "billingStartDate": "2019-08-28T00:00:00-07:00",
    "billingEndDate": "2019-09-27T00:00:00-07:00",
    "totalCost": 22.861172,
    "currencyLocale": "fr-FR",
    "lastModifiedDate": "2019-09-01T23:04:41.193+00:00",
    "links": {
        "self": {
            "uri": "/customers/<customer-tenant-id>/subscriptions/<subscription-id>/usagesummary",
            "method": "GET",
            "headers": []
        }
    },
    "attributes": {
        "objectType": "SubscriptionUsageSummary"
    }
}

Azure 方案的 REST 回應範例

在此範例中,客戶已購買 Azure 方案。

對於具有 Azure 方案的客戶,有下列 API 回應變更:

  • currencyLocale 會取代為 currencyCode
  • usdTotalCost 是新的欄位
HTTP/1.1 200 OK
Content-Length: 1120
Content-Type: application/json
MS-CorrelationId: 47c36033-af5d-4457-80a4-512c1626fac1
MS-RequestId: e128c8e2-4c33-4940-a3e2-2e59b0abdc67
Date: Tue, 17 Sep 2019 20:31:45 GMT

{
    "resourceId": "11111111-dca5-6f31-d3a6-dbbfad9be0fc",
    "resourceName": "Azure plan",
    "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",
    "links": {
        "self": {
            "uri": "/customers/<customer-tenant-id>/subscriptions/<subscription-id>/usagesummary",
            "method": "GET",
            "headers": []
        }
    },
    "attributes": {
        "objectType": "SubscriptionUsageSummary"
    }
}