Get a usage summary for all of a customer's subscriptions
Article
Applies to: Partner Center | Partner Center for Microsoft Cloud for US Government
You can use the CustomerUsageSummary resource to get a customer's usage of a specific Azure service or resource during the current billing period.
Note
Generally, daily rated unbilled usage data is available via API or the Partner Center portal after 24 hours. Depending on your location and when the meters report usage, additional delays might occur.
Sometimes, you might not see the most recent unbilled usage data from the beginning of the month until the previous month's billed usage data is delivered. This is to make sure the billed usage data is delivered efficiently within the SLA. Once you receive the billed usage data, you can start retrieving all the updated unbilled usage data from the beginning of the month.
Prerequisites
Credentials as described in Partner Center authentication. This scenario supports authentication with App+User credentials only.
A customer ID (customer-tenant-id). If you don't know the customer's ID, you can look it up in Partner Center by selecting the Customers workspace, then the customer from the customer list, then Account. On the customer's Account page, look for the Microsoft ID in the Customer Account Info section. The Microsoft ID is the same as the customer ID (customer-tenant-id).
C#
To get a usage summary for all of a customer's subscriptions:
Use your IAggregatePartner.Customers collection to call the ById() method.
Call the UsageSummary property, followed by the Get() or GetAsync() methods:
C#
// IAggregatePartner partnerOperations;// var selectedCustomerId as string;var usageSummary = partnerOperations.Customers.ById(selectedCustomerId).UsageSummary.Get();
If successful, this method returns a CustomerUsageSummary resource in the response body.
Response success and error codes
Each response comes with an HTTP status code that indicates success or failure and additional debugging information. Use a network trace tool to read this code, the error type, and additional parameters. For a full list, see Error Codes.
Response example for Microsoft Azure (MS-AZR-0145P) subscription
In this example, the customer purchased a 145P Azure PayG offer.
For customers with Microsoft Azure (MS-AZR-0145P) subscriptions, there will be no change to the API response.
You can use the AzureResourceMonthlyUsageRecord resource collection to get a list of services within a customer's subscription and their associated rated usage information.
With the Partner Center, Cloud Solution Provider partners can view and manage invoices, reconciliation line items, and customer's Azure spending budget programmatically.
Learn how Cloud Solution Provider program partners can use the Partner Center API to programmatically manage customer accounts, orders, support, and billing.