Applies to: Partner Center | Partner Center for Microsoft Cloud for US Government
You can use the AzureResourceMonthlyUsageRecord resource collection to get a list of services within a customer's subscription and their associated rated usage information.
Prerequisites
Credentials as described in Partner Center authentication. This scenario supports authentication with both standalone App and App+User credentials.
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).
To get a subscription's resource usage information:
Use your IAggregatePartner.Customers collection to call the ById() method.
Call the Subscriptions property, and UsageRecords, then the Resources property.
Call the Get() or GetAsync() methods.
C#
// IAggregatePartner partnerOperations;// var selectedCustomerId as string;// var selectedSubscriptionID as string;var usageRecords = partnerOperations.Customers.ById(selectedCustomerId).Subscriptions.ById(selectedSubscriptionId).UsageRecords.Resources.Get();
If successful, this method returns a collection of AzureResourceMonthlyUsageRecord resources 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, error type, and additional parameters. For the full list, see Error Codes.
With the Partner Center, Cloud Solution Provider partners can view and manage invoices, reconciliation line items, and customer's Azure spending budget programmatically.