다음을 통해 공유


미터별 구독 사용 현황 데이터 가져오기

적용 대상: 파트너 센터 | Microsoft Cloud for US Government 파트너 센터

MeterUsageRecord 리소스 컬렉션을 사용하여 현재 청구 기간 동안 특정 Azure 서비스 또는 리소스에 대한 고객의 미터 사용량 기록을 가져올 수 있습니다. 이 리소스 컬렉션은 전체 Azure 계획에서 현재 청구 주기 대한 각 미터에 대해 집계된 합계를 나타냅니다.

필수 구성 요소

  • 자격 증명(파트너 센터 인증에서 설명). 이 시나리오는 앱 + 사용자 자격 증명을 사용한 인증만 지원합니다.

  • 고객 ID (customer-tenant-id). 고객의 ID를 모르는 경우 고객 작업 영역, 고객 목록에서 고객, 계정을 차례로 선택하여 파트너 센터에서 조회할 수 있습니다. 고객 계정 페이지의 고객 계정 정보 섹션에서 Microsoft ID를 찾습니다. Microsoft ID는 고객 ID(customer-tenant-id)와 동일합니다.

  • 구독 ID

이 새 경로는 Microsoft Azure(MS-AZR-0145P) 구독에 대해서만 계속 작동하는 와 동일합니다 subscriptions/{subscription-id}/usagerecords/resources. 이 새 경로는 Microsoft Azure(MS-AZR-0145P) 구독과 Azure 요금제를 모두 지원합니다. Azure 계획에 대한 이 정보를 얻으려면 이 새 경로로 전환해야 합니다. 다음 섹션에 언급된 속성 외에 응답은 이전 경로와 동일합니다.

C#

현재 청구 기간 동안 특정 Azure 서비스 또는 리소스에 대한 고객의 미터 사용량 기록을 얻으려면 다음을 수행합니다.

  1. IAggregatePartner.Customers 컬렉션을 사용하여 ById() 메서드를 호출합니다.

  2. Subscriptions 속성 및 UsageRecords를 호출한 다음 미터 속성을 호출합니다. Get() 또는 GetAsync() 메서드를 호출하여 마칩니다.

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

예제는 다음 샘플을 참조하세요.

  • 샘플: 콘솔 테스트 앱
  • 프로젝트: PartnerSDK.FeatureSamples
  • 클래스: GetSubscriptionUsageRecordsByMeter.cs

REST 요청

요청 구문

방법 요청 URI
GET {baseURL}/v1/customers/{customer-tenant-id}/subscriptions/{subscription-id}/meterusagerecords HTTP/1.1

URI 매개 변수

이 표에는 고객의 등급 사용 정보를 가져오는 데 필요한 쿼리 매개 변수가 나열됩니다.

Name 형식 필수 Description
customer-tenant-id guid Y 고객에게 해당하는 GUID입니다.
subscription-id guid Y Microsoft Azure(MS-AZR-0145P) 구독 또는 Azure 플랜을 나타내는 파트너 센터 구독 리소스의 식별자에 해당하는 GUID입니다. Azure 플랜 구독 리소스의 경우 plan-id 를 이 경로의 subscription-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"
    }
}