Get Azure Consumption Report

Prev Next

URL

GET https://contosov2-prod-api.azurewebsites.net/api/azureConsumption/v3/customer/{{customerId}}//page/{{pageSize}}/startindex/{{startIndex}}/month/{{month}}/year/{{year}}/?date={{date}}&subscriptionId={{subscriptionId}}&entitlementId={{entitlementId}}& resourcegroup={{resourceGroup}}&resourcename={{resourceName}}

{{customerId}} – This is a mandatory parameter. Pass the Microsoft customer Id to this parameter to get the details of a particular customer.

{{subscriptionId}} – This is an optional parameter. Pass the subscription Id to this parameter to get the details of a particular subscription.

{{page}} – This is a mandatory parameter. Pass a value to this parameter to get desired number of records in the consumption report

{{startIndex}} – This is a mandatory parameter. Pass a value to this parameter to assign a start index. This is analogous to the page index and the results are treated page-wise with the number of records per page controlled by the pageSize value.

{{month}} – This is a mandatory parameter. Pass the calendar month number to this parameter to get the details of a month.1 – January, 2 – February, etc. The month corresponds to the month when the bill was generated from Microsoft. It translates to the consumption from the previous month.

Eg: Passing June, 2020 would get the consumption for the month of May as we are adding the date when the bill is generated in June, 2020 and this actually corresponds to the consumption reported in May.

{{year}} – This is a mandatory parameter. Pass the year to this parameter to get the details of a particular year. Only current year and the previous year are supported.

{{date}} – This is an optional parameter. Pass the date to this parameter to get the report for a particular day in the month and year.

{{entitlementId}} – This is an optional parameter. Pass the entitlementId to this parameter to get the details of an entitlement. Entitlement is relevant if the subscription is an Azure Plan subscription.

{{resourceGroup}} – This is an optional parameter. Pass the resource group name to this parameter to get the aggregates by resource group.

{{resourceName}} – This is an optional parameter. Pass the resource name to this parameter to get the details for a resource.

Request headers

Key

Value

Authorization

Bearer <access_token>

Content-Type

Application/json

Request body

The request requires parameters if only you want to apply filters by one of the optional parameters.

Response body

An example response for the request to get consumption report is as follows:

{
    "OperationType": null,
    "Status": "Success",
    "RequestCorrelationID": "f2cdf3b3-7043-463a-be65-ee6470ee11ac",
    "ErrorMessage": null,
    "ErrorDetail": null,
    "Data": [
        {
            "SubscriptionName": "Azure plan",
            "EntitlementName": "Azure subscription 1",
            "EntitlementId": "85BF4F5E-789B-4578-8928-7FB014373442",
            "AdditionalInfo": "",
            "ReservationId": null,
            "MeterId": "12df5678-0fa0-47c0-accd-96b7aee6361f",
            "ProductId": "DZH318Z0BP88",
            "SkuId": "00F3",
            "ConsumedService": "Microsoft.Compute",
            "ResourceURI": "/subscriptions/85BF4F5E-789B-4578-8928-7FB014373442/resourceGroups/RG-ABC-HG-CENTRALUS-01/providers/Microsoft.Sql/servers/sql-duxhg-01/elasticPools/sqlep-duxhg-01",
            "BenefitOrderId": "ed56cbi7-3e5c-1683-8da0-82b45f9b034e",
            "BenefitId": "4fg7c302-f836-4298-121d-fd9bba38fd9f",
            "BenefitType": "SavingsPlan",
            "ID": 1,
            "TenantId": "1267hj090-afcf-fch9-a93e-cf4bfb679a7e",
            "SubscriptionId": "bb2edc1a-91f0-03ae-8b9e-96543e42df34",
            "AzureResourceGroupName": "RG-ABC-HG-CENTRALUS-01",
            "AzureResourceCategory": "SQL Database",
            "AzureResourceSubCategory": "SQL Database Single/Elastic Pool General Purpose - SQL License",
            "AzureResourceType": "1 vCore Hour",
            "AzureResourceName": "sqlep-duxhg-01",
            "ChargeDate": "2024-09-01T00:00:00",
            "Quantity": 96.00000000,
            "Unit": "1 Hour",
            "ChargeForCustomer": 9.59673600,
            "ChargedByMS": 8.15709677,
            "ChargeForReseller": 8.15709677,
            "Location": "CENTRALUS",
            "Tags": "{\"SQLserverUS\":\"//subscriptions/85BF4F5E-789B-4578-8928-7FB014373442/resourceGroups/RG-ABC-HG-CENTRALUS-01/Microsoft.DesktopVirtualization/SQLServer/RG-ABC-HG-CENTRALUS-01\"}"
        },

Here is the explanation for the properties in the response (JSON)

Property

Description

OperationType

Can be ignored

Status

Indicates the status of the request. Possible values – Success / Error

RequestCorrelationID

Internal ID generated by C3 for correspondence for troubleshooting issues, if any.

ErrorMessage

Message in case the request runs into an error during processing

ErrorDetail

Additional detail related to the error in case there is an error while processing the request

Data

Contains a list of consumption report objects represented by the following attributes:

Attribute

Description

SubscriptionName

A unique identifier used in Microsoft's billing system, typically indicating the Azure plan ID for pay-as-you-go resources.

EntitlementName

Azure subscription name available if parent is Azure Plan, will be null if legacy Azure

EntitlementId

Azure subscription identifier (ID) available if parent is Azure Plan, will be null if legacy Azure

AdditionalInfo

Additional Information provided by MS in usage data

ReservationID

Reservation ID extracted from Additional Info

MeterID

A unique identifier of the meter provided by Microsoft in usage data

ProductID

Product ID provided by MS in usage data

SkuId

Stock-keeping unit (SKU) identifier provided by MS in usage data

ConsumedService

Azure platform service used, provided by MS in usage data

ResourceURI

URI of the resource provided by Microsoft in usage data

BenefitOrderId
A unique identifier for Azure savings plan, similar to the reservation order ID for Azure reservations. This field is optional for other products
BenefitId
A unique identifier for each Azure savings plan. This field is optional for other products.
BenefitType
An identifier indicating if this usage is covered by an Azure savings plan or subject to pay-as-you-go charges.

ID

Record Serial number in API output

TenantId

Microsoft Id of the customer

SubscriptionId

Subscription id for Azure Plan/Azure Subscription

AzureResourceGroupName

Name of Resource container

AzureResourceCategory

Name of resource category

AzureResourceSubCategory

Name of resource subcategory

AzureResourceType

Resource Type

AzureResourceName

Name of resource

ChargeDate

Consumption date

Quantity

Number of billed units

Unit

Unit to determine the charge amount

ChargeForCustomer

The amount charged to the customer by the Partner ( includes the margin )

ChargedByMS

The amount charged by MS

ChargeForReseller

The amount charged to the reseller ( not applicable in your case )

Location

Data center where the meter is running

Tags

User-defined logical structuring of Azure resources, created by subscriptions users.

Error response

The API validates the input parameters – Returns 400 â€“ Bad request error in case the input is found to be invalid.

A sample bad request error covering both the attributes is as follows:

{

    "OperationType": null,

    "Status": "Error",

"RequestCorrelationID": "fe8ff19e-b9eb-4a43-af0f-418e86b9b200",

"ErrorMessage": "ERROR_DESC_BAD_INPUT",

    "ErrorDetail": "ERROR_DESC_BAD_INPUT",

    "Data": [

        {

            "Atribute": "TenantId",

            "AtributeKey": "TENANT_ID",

            "Message": "INVALID_CUSTOMER_ID",

            "DefaultMessage": "Invalid Customer ID",

            "Value": "b8177a6b-868a-44e4-9bf7-b13dd5a13d01"

        }

The following table explains the constituents of the response in detail:

Property

Description

OperationType

Can be ignored

Status

Indicates the status of the request. Possible values – Success / Error

RequestCorrelationID

Internal ID generated by C3 for correspondence for troubleshooting issues, if any.

ErrorMessage

Message in case the request runs into an error during processing

ErrorDetail

Additional detail related to the error in case there is an error while processing the request

Data

Contains a list of validation errors represented by the following attributes:

  • Attribute – The input in the request that is invalid
  • AttributeKey – This is for internal purposes ( only used if we were to present custom labels to the user )
  • Message –Reason for the validation failure
  • DefaultMessage – error message in English
  • Value – input