다음을 통해 공유


리소스별 구독 사용 현황 데이터 가져오기

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

이 문서에서는 ResourceUsageRecord 리소스를 가져오는 방법을 설명합니다. 이 리소스는 Azure 플랜에 프로비전된 개별 리소스에 대한 월별 집계 합계를 나타냅니다. 이 리소스를 사용하여 현재 청구 기간 동안 특정 Azure 서비스 또는 리소스에 대한 고객의 리소스 사용 기록을 가져올 수 있습니다. 이 API는 Azure 지출 API를 통해 이전에 사용할 수 없었던 데이터를 반환합니다.

이 경로는 Microsoft Azure(MS-AZR-0145P) 구독을 지원하지 않습니다.

필수 구성 요소

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

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

  • 구독 식별자

C#

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

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

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

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

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

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

REST 요청

요청 구문

방법 요청 URI
GET {baseURL}/v1/customers/{customer-tenant-id}/subscriptions/{subscription-id}/resourceusagerecords 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}/resourceusagerecords 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<ResourceUsageRecord> 리소스를 반환합니다.

응답 성공 및 오류 코드

각 응답에는 성공 또는 실패와 추가 디버깅 정보를 나타내는 HTTP 상태 코드가 함께 제공됩니다. 네트워크 추적 도구를 사용하여 코드, 오류 유형 및 추가 매개 변수를 읽을 수 있습니다. 전체 목록은 오류 코드를 참조하세요.

응답 예제

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": 3,
    "items": [
        {
            "subscriptionId": "{subscription-id}",
            "resourceUri": "/subscriptions/{subscription-id}/resourceGroups/TESTRG1/providers/Microsoft.Compute/disks/testVM1_OsDisk_1_531d3c99534b4649ae025d485370143e",
            "resourceType": "Microsoft.Compute",
            "entitlementId": "{entitlemen-id}",
            "entitlementName": "Partner Subscription",
            "resourceGroupName": "TESTRG1",
            "name": "testVM1_OsDisk_1_531d3c99534b4649ae025d485370143e",
            "resourceName": "testVM1_OsDisk_1_531d3c99534b4649ae025d485370143e",
            "totalCost": 2.0211938955034572,
            "currencyCode": "GBP",
            "usdTotalCost": 2.4700000000000001,
            "lastModifiedDate": "2019-09-17T21:08:44.2566667+00:00",
            "attributes": {
                "objectType": "ResourceUsageRecord"
            }
        },
        {
            "subscriptionId": "{subscription-id}",
            "resourceUri": "/subscriptions/{subscription-id}/resourceGroups/TESTRG1/providers/Microsoft.Compute/virtualMachines/testVM1",
            "resourceType": "Microsoft.Compute",
            "entitlementId": "{entitlement-id}",
            "entitlementName": "Partner Subscription",
            "resourceGroupName": "TESTRG1",
            "name": "testVM1",
            "resourceName": "testVM1",
            "totalCost": 80.3322286322163563,
            "currencyCode": "GBP",
            "usdTotalCost": 98.1699999999999985,
            "lastModifiedDate": "2019-09-17T21:08:44.2566667+00:00",
            "attributes": {
                "objectType": "ResourceUsageRecord"
            }
        },
        {
            "subscriptionId": "{subscription-id}",
            "resourceUri": "/subscriptions/{subscription-id}/resourceGroups/testrg1/providers/Microsoft.Storage/storageAccounts/testrg1diag153",
            "resourceType": "Microsoft.Storage",
            "entitlementId": "{entitlemen-id}",
            "entitlementName": "Partner Subscription",
            "resourceGroupName": "testrg1",
            "name": "testrg1diag153",
            "resourceName": "testrg1diag153",
            "totalCost": 0.0081829712368561032,
            "currencyCode": "GBP",
            "usdTotalCost": 0.0099999999999999997,
            "lastModifiedDate": "2019-09-17T21:08:44.2566667+00:00",
            "attributes": {
                "objectType": "ResourceUsageRecord"
            }
        }
    ],
    "links": {
        "self": {
            "uri": "/customers/<customer-tenant-id>/subscriptions/<subscription-id>/resourceusagerecords",
            "method": "GET",
            "headers": []
        }
    },
    "attributes": {
        "objectType": "Collection"
    }
}