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

適用於:合作夥伴中心 |美國政府適用的 Microsoft Cloud 合作夥伴中心

您可以使用 CustomerUsageSummary 資源,取得客戶在目前計費期間內特定 Azure 服務或資源的使用量。

注意

一般而言,每日評分的未計費使用量數據可在24小時後透過API或合作夥伴中心入口網站取得。 視您的位置和計量報告使用量而定,可能會發生額外的延遲。

有時候,您可能不會看到從月初開始的最新未計費使用量數據,直到傳遞上個月的計費使用量數據為止。 這是為了確保計費使用量數據會在 SLA 內有效率地傳遞。 收到計費使用量數據之後,您就可以開始從月初擷取所有已更新的未計費使用量數據。

必要條件

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"
    }
}