サブスクリプションの使用状況データをメーターごとに取得する

適用対象: パートナー センター | Microsoft Cloud for US Government のパートナー センター

MeterUsageRecord リソース コレクションを使用すると、現在の請求期間中に特定の Azure サービスまたはリソースの顧客の使用状況測定レコードを取得できます。 このリソース コレクションは、Azure プラン全体の現在の支払いサイクルのメーターごとに集計された合計を表します。

前提条件

  • パートナー センターの認証に関するページで説明している資格情報。 このシナリオでは、アプリとユーザーの資格情報を使用した認証のみがサポートされます。

  • 顧客 ID です (customer-tenant-id)。 顧客の ID がわからない場合は、 パートナー センター で [顧客] ワークスペースを選択し、 次に顧客 の一覧から顧客を探し、[ アカウント] を選択します。 お客様のアカウント ページで、 [顧客のアカウント情報] セクションの Microsoft ID を探します。 Microsoft ID は、顧客 ID (customer-tenant-id) と同じです。

  • サブスクリプション ID

この新しいルートは と同じです subscriptions/{subscription-id}/usagerecords/resources。これは、Microsoft Azure (MS-AZR-0145P) サブスクリプションに対してのみ機能し続けます。 この新しいルートでは、Microsoft Azure (MS-AZR-0145P) サブスクリプションと Azure プランの両方がサポートされます。 Azure プランのこの情報を取得するには、この新しいルートに切り替える必要があります。 以降のセクションで説明するプロパティ以外の応答は、古いルートと同じです。

C#

現在の請求期間中に特定の Azure サービスまたはリソースの顧客の使用状況測定レコードを取得するには:

  1. ById() メソッドを呼び出すには、IAggregatePartner.Customers コレクションを使用します。

  2. Subscriptions プロパティと UsageRecords を呼び出し、 次に Meters プロパティを呼び出します。 Get() メソッドまたは GetAsync() メソッドを呼び出して完了します。

    // IAggregatePartner partnerOperations;
    // var selectedCustomerId as string;
    // var selectedSubscriptionId as string;
    
    var usageRecords = partnerOperations.Customers.ById(selectedCustomerId).Subscriptions.ById(selectedSubscriptionId).UsageRecords.Meters.Get();
    

例については、次のサンプルを参照してください。

REST 要求

要求の構文

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

URI パラメーター

次の表に、顧客の評価された使用状況情報を取得するために必要なクエリ パラメーターの一覧を示します。

名前 Type 必須 説明
customer-tenant-id guid Y 顧客に対応する GUID。
subscription-id guid Y Microsoft Azure (MS-AZR-0145P) サブスクリプションまたは Azure プランを表すパートナー センター サブスクリプション リソースの識別子に対応する GUID。 Azure プラン サブスクリプション リソースの場合は、このルートのサブスクリプション ID として plan-id を指定します。

要求ヘッダー

詳細については、「パートナー センター REST ヘッダー」を参照してください。

[要求本文]

なし。

要求の例

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

REST 応答

成功した場合、このメソッドは応答本文で PagedResourceCollection<MeterUsageRecord> リソースを返します。

応答の成功とエラーのコード

各応答には、成功または失敗を示す 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

{
    "totalCount": 1,
    "items": [
        {
            "status": "active",
            "offerId": "MS-AZR-0145P",
            "resourceId": "11111111-F347-41B6-B02C-187B1B778A43",
            "id": "11111111-F347-41B6-B02C-187B1B778A43",
            "resourceName": "Microsoft Azure",
            "name": "Microsoft Azure",
            "totalCost": 22.861172,
            "currencyLocale": "fr-FR",
            "usdTotalCost": 0,
            "lastModifiedDate": "2019-09-01T23:04:41.193+00:00",
            "attributes": {
                "objectType": "SubscriptionMonthlyUsageRecord"
            }
        }
    ],
    "links": {
        "self": {
            "uri": "/customers/{customer-tenant-id}/subscriptions/usagerecords/",
            "method": "GET",
            "headers": []
        }
    },
    "attributes": {
        "objectType": "Collection"
    }
}

Azure プランの REST 応答の例

この例では、顧客が Azure プランを購入しました。

Azure プランをお持ちのお客様の場合、API 応答には次の変更があります。

  • currencyLocalecurrencyCode に置き換えられます
  • 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: Fri, 26 Feb 2016 20:31:45 GMT

{
    "totalCount": 4,
    "items": [
        {
            "subscriptionId": "{subscription-id}",
            "meterId": "DZH318Z0BNVX-005J-Data Transfer In (GB)",
            "meterName": "Data Transfer In",
            "category": "Bandwidth",
            "subcategory": "Bandwidth",
            "quantityUsed": 0.01129,
            "unit": "1 GB",
            "totalCost": 0,
            "currencyCode": "GBP",
            "usdTotalCost": 0,
            "lastModifiedDate": "2019-09-17T21:08:44.2566667+00:00",
            "attributes": {
                "objectType": "MeterUsageRecord"
            }
        },
        {
            "subscriptionId": "{subscription-id}",
            "meterId": "DZH318Z0BNVX-005J-Data Transfer Out (GB)",
            "meterName": "Data Transfer Out",
            "category": "Bandwidth",
            "subcategory": "Bandwidth",
            "quantityUsed": 0.000224,
            "unit": "1 GB",
            "totalCost": 0,
            "currencyCode": "GBP",
            "usdTotalCost": 0,
            "lastModifiedDate": "2019-09-17T21:08:44.2566667+00:00",
            "attributes": {
                "objectType": "MeterUsageRecord"
            }
        },
        {
            "subscriptionId": "{subscription-id}",
            "meterId": "DZH318Z0BNZ5-006G-10K Batch Write Operations",
            "meterName": "Batch Write Operations",
            "category": "Storage",
            "subcategory": "Tables",
            "quantityUsed": 0.2462,
            "unit": "10K",
            "totalCost": 0,
            "currencyCode": "GBP",
            "usdTotalCost": 0,
            "lastModifiedDate": "2019-09-17T21:08:44.2566667+00:00",
            "attributes": {
                "objectType": "MeterUsageRecord"
            }
        },
        {
            "subscriptionId": "{subscription-id}",
            "meterId": "DZH318Z0BNZ5-006G-Data Stored (GB/Month)",
            "meterName": "LRS Data Stored",
            "category": "Storage",
            "subcategory": "Tables",
            "quantityUsed": 0.002632,
            "unit": "1 GB/Month",
            "totalCost": 0,
            "currencyCode": "GBP",
            "usdTotalCost": 0,
            "lastModifiedDate": "2019-09-17T21:08:44.2566667+00:00",
            "attributes": {
                "objectType": "MeterUsageRecord"
            }
        }
    ],
    "links": {
        "self": {
            "uri": "/customers/<customer-tenant-id>/subscriptions/<subscription-id>/meterusagerecords",
            "method": "GET",
            "headers": []
        }
    },
    "attributes": {
        "objectType": "Collection"
    }
}