共用方式為


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

適用於:微軟合作夥伴中心 | 美國政府雲端合作夥伴中心

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

注意

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

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

先決條件

  • 合作夥伴中心驗證中所描述的資格認證。 此案例僅支援使用 App+User 認證進行驗證。

  • 客戶標識碼 (customer-tenant-id)。 如果您不知道客戶的標識碼,您可以先在 合作夥伴中心 中選取 [客戶 工作區],然後從客戶清單中選取客戶,接著選擇 帳戶以查閱。 在客戶的 [帳戶] 頁面上,於 [客戶帳戶資訊] 區段中尋找 Microsoft 帳戶識別碼。 Microsoft識別碼與客戶標識碼 (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
取得 {baseURL}/v1/customers/{customer-tenant-id}/usagesummary HTTP/1.1

URI 參數

下表列出必要的查詢參數,以取得客戶的評等使用量資訊。

名字 類型 必填 描述
用戶租戶識別碼 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: aaaa0000-bb11-2222-33cc-444444dddddd

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: aaaa0000-bb11-2222-33cc-444444dddddd
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 回應有下列變更:

  • 貨幣區域 被取代為 貨幣代碼
  • usdTotalCost 是新的欄位
HTTP/1.1 200 OK
Content-Length: 1120
Content-Type: application/json
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
MS-RequestId: e128c8e2-4c33-4940-a3e2-2e59b0abdc67
Date: Tue, 17 Sep 2019 20:31:45 GMT

{
    "budget": {
        "amount": 97,
        "attributes": {
            "objectType": "SpendingBudget"
        }
    },
    "resourceId": "a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1",
    "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"
    }
}