Get Azure Consumption Report
    • 16 Jul 2023
    • 4 Minutes to read
    • Dark
      Light
    • PDF

    Get Azure Consumption Report

    • Dark
      Light
    • PDF

    Article Summary

    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:

    {
    
                "SubscriptionName": "ABC - Azure plan",
    
                "EntitlementName": "ABC - Azure subscription 1",
    
                "EntitlementId": "85bf4f5e-1234-4886-8928-7fb014373442",
    
                "AdditionalInfo": "{  \"AHB\": \"False\",  \"vCores\": 4}",
    
                "ReservationId": null,
    
                "MeterId": "6f344f4b-7c91-4026-915a-a1b597793be1",
    
                "ProductId": "DZH318Z0BQDL",
    
                "SkuId": "001H",
    
                "ConsumedService": "Microsoft.Sql",
    
                "ResourceURI": "/subscriptions/85BF4F5E-789B-4578-8928-7FB014373442/resourceGroups/RG-ABC-HG-CENTRALUS-01/providers/Microsoft.Sql/servers/sql-duxhg-01/elasticPools/sqlep-duxhg-01",
    
                "ID": 1,
    
                "TenantId": "fb679a7e-3345-4789-abe3-6fad969d58da",
    
                "SubscriptionId": "bb2edc1a-91f0-03ae-8b9e-96543e42df38",
    
                "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": "2022-08-23T00:00:00",
    
                "Quantity": 96.00000000,
    
                "Unit": "1 Hour",
    
                "ChargeForCustomer": 9.59673600,
    
                "ChargedByMS": 8.15709677,
    
                "ChargeForReseller": 8.15709677,
    
                "Location": "CENTRALUS",
    
                "Tags": ""
    
            },
    
    …
    
    ]

    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

    Azure Subscription /Azure Plan Name

    EntitlementName

    Entitlement Name (if parent is Azure Plan), will be null if legacy Azure

    EntitlementId

    Entitlement Id (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

    Meter ID provided by MS in usage data

    ProductID

    Product ID provided by MS in usage data

    SkuId

    Sku Id provided by MS in usage data

    ConsumedService

    Consumed Service provided by MS in usage data

    ResourceURI

    Resource URI provided by MS in usage data

    ID

    Record Serial number in API output

    TenantId

    Microsoft Id of the customer

    SubscriptionId

    Subscription id for Azure Plan/Azure Subscription

    AzureResourceGroupName

    Name of the resource group

    AzureResourceCategory

    Name of resource category

    AzureResourceSubCategory

    Name of resource subcategory

    AzureResourceType

    Resource Type

    AzureResourceName

    Name of resource

    ChargeDate

    Consumption date

    Quantity

    Quantity considered for the line item

    Unit

    Unit

    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

    Resource Location

    Tags

    associated tags, if created

    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

    Was this article helpful?