Lists the usage details for the defined scope. Usage details are available via this API only for May 1, 2014 or later.
Note:Microsoft will be retiring the Consumption Usage Details API at some point in the future. We do not recommend that you take a new dependency on this API. Please use the Cost Details API instead. We will notify customers once a date for retirement has been determined.For Learn more,see Generate Cost Details Report - Create Operation
GET https://management.azure.com/{scope}/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
With optional parameters:
GET https://management.azure.com/{scope}/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01&$expand={$expand}&$filter={$filter}&$skiptoken={$skiptoken}&$top={$top}&metric={metric}
URI Parameters
| Name |
In |
Required |
Type |
Description |
|
scope
|
path |
True
|
string
|
The fully qualified Azure Resource manager identifier of the resource.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
The API version to use for this operation.
|
|
$expand
|
query |
|
string
|
May be used to expand the properties/additionalInfo or properties/meterDetails within a list of usage details. By default, these fields are not included when listing usage details.
|
|
$filter
|
query |
|
string
|
May be used to filter usageDetails by properties/resourceGroup, properties/resourceName, properties/resourceId, properties/chargeType, properties/reservationId, properties/publisherType or tags. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:). PublisherType Filter accepts two values azure and marketplace and it is currently supported for Web Direct Offer Type
|
|
$skiptoken
|
query |
|
string
|
Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent calls.
|
|
$top
|
query |
|
integer
(int32)
minimum: 1 maximum: 1000
|
May be used to limit the number of results to the most recent N usageDetails.
|
|
metric
|
query |
|
Metrictype
|
Allows to select different type of cost/usage records.
|
Responses
| Name |
Type |
Description |
|
200 OK
|
UsageDetailsListResult
|
The request has succeeded.
|
|
204 No Content
|
|
Operation completed successfully.
|
|
Other Status Codes
|
ErrorResponse
|
An unexpected error response.
|
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
| Name |
Description |
|
user_impersonation
|
impersonate your user account
|
Examples
BillingAccountUsageDetailsList-Legacy
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_by_billing_account.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="providers/Microsoft.Billing/BillingAccounts/1234",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListByBillingAccount.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListByBillingAccount.json
func ExampleUsageDetailsClient_NewListPager_billingAccountUsageDetailsListLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/BillingAccounts/1234", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("Account Name 1"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.0000000Z"); return t}()),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product Name 1"),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceName: to.Ptr("Resource Name 1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "Account Name 1",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Account Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-03-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-03-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"cost": 0.000295194820065,
"costCenter": "DEV",
"date": "2019-03-30T00:00:00.0000000Z",
"effectivePrice": 0.000402776395232,
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product Name 1",
"quantity": 0.7329,
"resourceGroup": "Resource Group 1",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"resourceLocation": "USEast",
"resourceName": "Resource Name 1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"unitPrice": 4.38
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
BillingAccountUsageDetailsList-Modern
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234:56789/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_by_mca_billing_account.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="providers/Microsoft.Billing/BillingAccounts/1234:56789",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListByMCABillingAccount.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListByMCABillingAccount.json
func ExampleUsageDetailsClient_NewListPager_billingAccountUsageDetailsListModern() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/BillingAccounts/1234:56789", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.ModernUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindModern),
// Properties: &armconsumption.ModernUsageDetailProperties{
// AdditionalInfo: to.Ptr("{ \"UsageType\": \"ComputeHR\", \"ImageType\": \"Windows Client BYOL\", \"ServiceType\": \"Standard_D1\", \"VMName\": null, \"VMProperties\": null, \"VCPUs\": 1, \"CPUs\": 0}"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("1234:56789"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrencyCode: to.Ptr("USD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("2468"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// CustomerName: to.Ptr("Modern Azure Customer 1"),
// CustomerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-30T00:00:00.0000000Z"); return t}()),
// ExchangeRate: to.Ptr("1"),
// ExchangeRateDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-30T00:00:00Z"); return t}()),
// Frequency: to.Ptr("UsageBased"),
// InstanceName: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// InvoiceID: to.Ptr(""),
// InvoiceSectionID: to.Ptr("98765"),
// InvoiceSectionName: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// PartnerEarnedCreditApplied: to.Ptr("0"),
// PartnerName: to.Ptr("Partner Name 1"),
// PartnerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// PreviousInvoiceID: to.Ptr(""),
// PricingCurrencyCode: to.Ptr("USD"),
// Product: to.Ptr("Virtual Machines D Series - D1 - US East"),
// ProductIdentifier: to.Ptr("DZH318Z0BQ4B00FV"),
// ProductOrderID: to.Ptr("a3db7880-70eb-4b4c-6a79-1425a058df5a"),
// ProductOrderName: to.Ptr("Azure plan"),
// PublisherID: to.Ptr(""),
// PublisherName: to.Ptr("Microsoft"),
// PublisherType: to.Ptr("Microsoft"),
// ResellerMpnID: to.Ptr(""),
// ResellerName: to.Ptr("Reseller Name 1"),
// ReservationID: to.Ptr(""),
// ReservationName: to.Ptr(""),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceLocationNormalized: to.Ptr("US East"),
// ServiceInfo1: to.Ptr(""),
// ServiceInfo2: to.Ptr("Windows Client BYOL"),
// ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00Z"); return t}()),
// ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00Z"); return t}()),
// SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// Term: to.Ptr(""),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/providers/Microsoft.Billing/BillingAccounts/1234:56789/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "modern",
"properties": {
"additionalInfo": "{ \"UsageType\": \"ComputeHR\", \"ImageType\": \"Windows Client BYOL\", \"ServiceType\": \"Standard_D1\", \"VMName\": null, \"VMProperties\": null, \"VCPUs\": 1, \"CPUs\": 0}",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "1234:56789",
"billingAccountName": "Account Name 1",
"billingCurrencyCode": "USD",
"billingPeriodEndDate": "2019-10-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-09-01T00:00:00.0000000Z",
"billingProfileId": "2468",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"costCenter": "DEV",
"costInBillingCurrency": 1.84763819095477,
"costInPricingCurrency": 1.84763819095477,
"costInUSD": 1.84763819095477,
"customerName": "Modern Azure Customer 1",
"customerTenantId": "00000000-0000-0000-0000-000000000000",
"date": "2019-10-30T00:00:00.0000000Z",
"exchangeRate": "1",
"exchangeRateDate": "2019-09-30T00:00:00Z",
"exchangeRatePricingToBilling": 0.077,
"frequency": "UsageBased",
"instanceName": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"invoiceId": "",
"invoiceSectionId": "98765",
"invoiceSectionName": "Invoice Section 1",
"isAzureCreditEligible": false,
"marketPrice": 0.077,
"meterId": "00000000-0000-0000-0000-000000000000",
"partnerEarnedCreditApplied": "0",
"partnerEarnedCreditRate": 0.077,
"partnerName": "Partner Name 1",
"partnerTenantId": "00000000-0000-0000-0000-000000000000",
"paygCostInBillingCurrency": 1.848,
"paygCostInUSD": 1.848,
"previousInvoiceId": "",
"pricingCurrencyCode": "USD",
"product": "Virtual Machines D Series - D1 - US East",
"productIdentifier": "DZH318Z0BQ4B00FV",
"productOrderId": "a3db7880-70eb-4b4c-6a79-1425a058df5a",
"productOrderName": "Azure plan",
"publisherId": "",
"publisherName": "Microsoft",
"publisherType": "Microsoft",
"quantity": 0.7329,
"resellerMpnId": "",
"resellerName": "Reseller Name 1",
"reservationId": "",
"reservationName": "",
"resourceGroup": "Resource Group 1",
"resourceLocation": "USEast",
"resourceLocationNormalized": "US East",
"serviceInfo1": "",
"serviceInfo2": "Windows Client BYOL",
"servicePeriodEndDate": "2019-12-01T00:00:00Z",
"servicePeriodStartDate": "2019-09-01T00:00:00Z",
"subscriptionGuid": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"term": "",
"unitPrice": 4.38
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
BillingAccountUsageDetailsListForBillingPeriod-Legacy
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_for_billing_period_by_billing_account.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="providers/Microsoft.Billing/BillingAccounts/1234",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListForBillingPeriodByBillingAccount.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListForBillingPeriodByBillingAccount.json
func ExampleUsageDetailsClient_NewListPager_billingAccountUsageDetailsListForBillingPeriodLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/BillingAccounts/1234", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("Account Name 1"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.0000000Z"); return t}()),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product Name 1"),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceName: to.Ptr("Resource Name 1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "Account Name 1",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Account Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-03-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-03-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"cost": 0.000342194841184,
"costCenter": "DEV",
"date": "2019-03-30T00:00:00.0000000Z",
"effectivePrice": 0.010534556373432,
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product Name 1",
"quantity": 0.8234,
"resourceGroup": "Resource Group 1",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"resourceLocation": "USEast",
"resourceName": "Resource Name 1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"unitPrice": 3.74
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
BillingProfileUsageDetailsList-Modern
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/2468/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_by_mca_billing_profile.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/2468",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListByMCABillingProfile.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListByMCABillingProfile.json
func ExampleUsageDetailsClient_NewListPager_billingProfileUsageDetailsListModern() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/2468", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.ModernUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/2468/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindModern),
// Properties: &armconsumption.ModernUsageDetailProperties{
// AdditionalInfo: to.Ptr("{ \"UsageType\": \"ComputeHR\", \"ImageType\": \"Windows Client BYOL\", \"ServiceType\": \"Standard_D1\", \"VMName\": null, \"VMProperties\": null, \"VCPUs\": 1, \"CPUs\": 0}"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("1234:56789"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrencyCode: to.Ptr("USD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("2468"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// CustomerName: to.Ptr("Modern Azure Customer 1"),
// CustomerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-30T00:00:00.0000000Z"); return t}()),
// ExchangeRate: to.Ptr("1"),
// ExchangeRateDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-30T00:00:00Z"); return t}()),
// Frequency: to.Ptr("UsageBased"),
// InstanceName: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// InvoiceID: to.Ptr(""),
// InvoiceSectionID: to.Ptr("98765"),
// InvoiceSectionName: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// PartnerEarnedCreditApplied: to.Ptr("0"),
// PartnerName: to.Ptr("Partner Name 1"),
// PartnerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// PreviousInvoiceID: to.Ptr(""),
// PricingCurrencyCode: to.Ptr("USD"),
// Product: to.Ptr("Virtual Machines D Series - D1 - US East"),
// ProductIdentifier: to.Ptr("DZH318Z0BQ4B00FV"),
// ProductOrderID: to.Ptr("a3db7880-70eb-4b4c-6a79-1425a058df5a"),
// ProductOrderName: to.Ptr("Azure plan"),
// PublisherID: to.Ptr(""),
// PublisherName: to.Ptr("Microsoft"),
// PublisherType: to.Ptr("Microsoft"),
// ResellerMpnID: to.Ptr(""),
// ResellerName: to.Ptr("Reseller Name 1"),
// ReservationID: to.Ptr(""),
// ReservationName: to.Ptr(""),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceLocationNormalized: to.Ptr("US East"),
// ServiceInfo1: to.Ptr(""),
// ServiceInfo2: to.Ptr("Windows Client BYOL"),
// ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00Z"); return t}()),
// ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00Z"); return t}()),
// SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// Term: to.Ptr(""),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/2468/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "modern",
"properties": {
"additionalInfo": "{ \"UsageType\": \"ComputeHR\", \"ImageType\": \"Windows Client BYOL\", \"ServiceType\": \"Standard_D1\", \"VMName\": null, \"VMProperties\": null, \"VCPUs\": 1, \"CPUs\": 0}",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "1234:56789",
"billingAccountName": "Account Name 1",
"billingCurrencyCode": "USD",
"billingPeriodEndDate": "2019-10-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-09-01T00:00:00.0000000Z",
"billingProfileId": "2468",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"costCenter": "DEV",
"costInBillingCurrency": 1.84763819095477,
"costInPricingCurrency": 1.84763819095477,
"costInUSD": 1.84763819095477,
"customerName": "Modern Azure Customer 1",
"customerTenantId": "00000000-0000-0000-0000-000000000000",
"date": "2019-10-30T00:00:00.0000000Z",
"exchangeRate": "1",
"exchangeRateDate": "2019-09-30T00:00:00Z",
"exchangeRatePricingToBilling": 0.077,
"frequency": "UsageBased",
"instanceName": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"invoiceId": "",
"invoiceSectionId": "98765",
"invoiceSectionName": "Invoice Section 1",
"isAzureCreditEligible": false,
"marketPrice": 0.077,
"meterId": "00000000-0000-0000-0000-000000000000",
"partnerEarnedCreditApplied": "0",
"partnerEarnedCreditRate": 0.077,
"partnerName": "Partner Name 1",
"partnerTenantId": "00000000-0000-0000-0000-000000000000",
"paygCostInBillingCurrency": 1.848,
"paygCostInUSD": 1.848,
"previousInvoiceId": "",
"pricingCurrencyCode": "USD",
"product": "Virtual Machines D Series - D1 - US East",
"productIdentifier": "DZH318Z0BQ4B00FV",
"productOrderId": "a3db7880-70eb-4b4c-6a79-1425a058df5a",
"productOrderName": "Azure plan",
"publisherId": "",
"publisherName": "Microsoft",
"publisherType": "Microsoft",
"quantity": 0.7329,
"resellerMpnId": "",
"resellerName": "Reseller Name 1",
"reservationId": "",
"reservationName": "",
"resourceGroup": "Resource Group 1",
"resourceLocation": "USEast",
"resourceLocationNormalized": "US East",
"serviceInfo1": "",
"serviceInfo2": "Windows Client BYOL",
"servicePeriodEndDate": "2019-12-01T00:00:00Z",
"servicePeriodStartDate": "2019-09-01T00:00:00Z",
"subscriptionGuid": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"term": "",
"unitPrice": 4.38
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
CustomerUsageDetailsList-Modern
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234:56789/customers/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_by_mca_customer.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="providers/Microsoft.Billing/BillingAccounts/1234:56789/customers/00000000-0000-0000-0000-000000000000",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListByMCACustomer.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListByMCACustomer.json
func ExampleUsageDetailsClient_NewListPager_customerUsageDetailsListModern() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/BillingAccounts/1234:56789/customers/00000000-0000-0000-0000-000000000000", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.ModernUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789/customers/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindModern),
// Properties: &armconsumption.ModernUsageDetailProperties{
// AdditionalInfo: to.Ptr("{ \"UsageType\": \"ComputeHR\", \"ImageType\": \"Windows Client BYOL\", \"ServiceType\": \"Standard_D1\", \"VMName\": null, \"VMProperties\": null, \"VCPUs\": 1, \"CPUs\": 0}"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("1234:56789"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrencyCode: to.Ptr("USD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("2468"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// CustomerName: to.Ptr("Modern Azure Customer 1"),
// CustomerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-30T00:00:00.0000000Z"); return t}()),
// ExchangeRate: to.Ptr("1"),
// ExchangeRateDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-30T00:00:00Z"); return t}()),
// Frequency: to.Ptr("UsageBased"),
// InstanceName: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// InvoiceID: to.Ptr(""),
// InvoiceSectionID: to.Ptr("98765"),
// InvoiceSectionName: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// PartnerEarnedCreditApplied: to.Ptr("0"),
// PartnerName: to.Ptr("Partner Name 1"),
// PartnerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// PreviousInvoiceID: to.Ptr(""),
// PricingCurrencyCode: to.Ptr("USD"),
// Product: to.Ptr("Virtual Machines D Series - D1 - US East"),
// ProductIdentifier: to.Ptr("DZH318Z0BQ4B00FV"),
// ProductOrderID: to.Ptr("a3db7880-70eb-4b4c-6a79-1425a058df5a"),
// ProductOrderName: to.Ptr("Azure plan"),
// PublisherID: to.Ptr(""),
// PublisherName: to.Ptr("Microsoft"),
// PublisherType: to.Ptr("Microsoft"),
// ResellerMpnID: to.Ptr(""),
// ResellerName: to.Ptr("Reseller Name 1"),
// ReservationID: to.Ptr(""),
// ReservationName: to.Ptr(""),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceLocationNormalized: to.Ptr("US East"),
// ServiceInfo1: to.Ptr(""),
// ServiceInfo2: to.Ptr("Windows Client BYOL"),
// ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00Z"); return t}()),
// ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00Z"); return t}()),
// SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// Term: to.Ptr(""),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/providers/Microsoft.Billing/BillingAccounts/1234:56789/customers/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "modern",
"properties": {
"additionalInfo": "{ \"UsageType\": \"ComputeHR\", \"ImageType\": \"Windows Client BYOL\", \"ServiceType\": \"Standard_D1\", \"VMName\": null, \"VMProperties\": null, \"VCPUs\": 1, \"CPUs\": 0}",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "1234:56789",
"billingAccountName": "Account Name 1",
"billingCurrencyCode": "USD",
"billingPeriodEndDate": "2019-10-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-09-01T00:00:00.0000000Z",
"billingProfileId": "2468",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"costCenter": "DEV",
"costInBillingCurrency": 1.84763819095477,
"costInPricingCurrency": 1.84763819095477,
"costInUSD": 1.84763819095477,
"customerName": "Modern Azure Customer 1",
"customerTenantId": "00000000-0000-0000-0000-000000000000",
"date": "2019-10-30T00:00:00.0000000Z",
"exchangeRate": "1",
"exchangeRateDate": "2019-09-30T00:00:00Z",
"exchangeRatePricingToBilling": 0.077,
"frequency": "UsageBased",
"instanceName": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"invoiceId": "",
"invoiceSectionId": "98765",
"invoiceSectionName": "Invoice Section 1",
"isAzureCreditEligible": false,
"marketPrice": 0.077,
"meterId": "00000000-0000-0000-0000-000000000000",
"partnerEarnedCreditApplied": "0",
"partnerEarnedCreditRate": 0.077,
"partnerName": "Partner Name 1",
"partnerTenantId": "00000000-0000-0000-0000-000000000000",
"paygCostInBillingCurrency": 1.848,
"paygCostInUSD": 1.848,
"previousInvoiceId": "",
"pricingCurrencyCode": "USD",
"product": "Virtual Machines D Series - D1 - US East",
"productIdentifier": "DZH318Z0BQ4B00FV",
"productOrderId": "a3db7880-70eb-4b4c-6a79-1425a058df5a",
"productOrderName": "Azure plan",
"publisherId": "",
"publisherName": "Microsoft",
"publisherType": "Microsoft",
"quantity": 0.7329,
"resellerMpnId": "",
"resellerName": "Reseller Name 1",
"reservationId": "",
"reservationName": "",
"resourceGroup": "Resource Group 1",
"resourceLocation": "USEast",
"resourceLocationNormalized": "US East",
"serviceInfo1": "",
"serviceInfo2": "Windows Client BYOL",
"servicePeriodEndDate": "2019-12-01T00:00:00Z",
"servicePeriodStartDate": "2019-09-01T00:00:00Z",
"subscriptionGuid": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"term": "",
"unitPrice": 4.38
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
DepartmentUsageDetailsList-Legacy
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/Departments/1234/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_by_department.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="providers/Microsoft.Billing/Departments/1234",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListByDepartment.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListByDepartment.json
func ExampleUsageDetailsClient_NewListPager_departmentUsageDetailsListLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/Departments/1234", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/providers/Microsoft.Billing/Departments/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("Account Name 1"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.0000000Z"); return t}()),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product Name 1"),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceName: to.Ptr("Resource Name 1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/providers/Microsoft.Billing/Departments/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "Account Name 1",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Account Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-03-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-03-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"cost": 0.000295194820065,
"costCenter": "DEV",
"date": "2019-03-30T00:00:00.0000000Z",
"effectivePrice": 0.000402776395232,
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product Name 1",
"quantity": 0.7329,
"resourceGroup": "Resource Group 1",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"resourceLocation": "USEast",
"resourceName": "Resource Name 1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"unitPrice": 4.38
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
DepartmentUsageDetailsListForBillingPeriod-Legacy
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/Departments/1234/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_for_billing_period_by_department.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="providers/Microsoft.Billing/Departments/1234",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListForBillingPeriodByDepartment.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListForBillingPeriodByDepartment.json
func ExampleUsageDetailsClient_NewListPager_departmentUsageDetailsListForBillingPeriodLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/Departments/1234", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/providers/Microsoft.Billing/Departments/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("Account Name 1"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.0000000Z"); return t}()),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product Name 1"),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceName: to.Ptr("Resource Name 1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/providers/Microsoft.Billing/Departments/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "Account Name 1",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Account Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-03-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-03-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"cost": 0.000342194841184,
"costCenter": "DEV",
"date": "2019-03-30T00:00:00.0000000Z",
"effectivePrice": 0.010534556373432,
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product Name 1",
"quantity": 0.8234,
"resourceGroup": "Resource Group 1",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"resourceLocation": "USEast",
"resourceName": "Resource Name 1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"unitPrice": 3.74
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
EnrollmentAccountUsageDetailsList-Legacy
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/EnrollmentAccounts/1234/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_by_enrollment_account.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="providers/Microsoft.Billing/EnrollmentAccounts/1234",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListByEnrollmentAccount.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListByEnrollmentAccount.json
func ExampleUsageDetailsClient_NewListPager_enrollmentAccountUsageDetailsListLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/EnrollmentAccounts/1234", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/providers/Microsoft.Billing/EnrollmentAccounts/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("Account Name 1"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.0000000Z"); return t}()),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product Name 1"),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceName: to.Ptr("Resource Name 1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/providers/Microsoft.Billing/EnrollmentAccounts/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "Account Name 1",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Account Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-03-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-03-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"cost": 0.000295194820065,
"costCenter": "DEV",
"date": "2019-03-30T00:00:00.0000000Z",
"effectivePrice": 0.000402776395232,
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product Name 1",
"quantity": 0.7329,
"resourceGroup": "Resource Group 1",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"resourceLocation": "USEast",
"resourceName": "Resource Name 1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"unitPrice": 4.38
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
EnrollmentAccountUsageDetailsListForBillingPeriod-Legacy
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/EnrollmentAccounts/1234/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_for_billing_period_by_enrollment_account.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="providers/Microsoft.Billing/EnrollmentAccounts/1234",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListForBillingPeriodByEnrollmentAccount.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListForBillingPeriodByEnrollmentAccount.json
func ExampleUsageDetailsClient_NewListPager_enrollmentAccountUsageDetailsListForBillingPeriodLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/EnrollmentAccounts/1234", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/providers/Microsoft.Billing/EnrollmentAccounts/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("Account Name 1"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.0000000Z"); return t}()),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product Name 1"),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceName: to.Ptr("Resource Name 1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/providers/Microsoft.Billing/EnrollmentAccounts/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "Account Name 1",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Account Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-03-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-03-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"cost": 0.000342194841184,
"costCenter": "DEV",
"date": "2019-03-30T00:00:00.0000000Z",
"effectivePrice": 0.010534556373432,
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product Name 1",
"quantity": 0.8234,
"resourceGroup": "Resource Group 1",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"resourceLocation": "USEast",
"resourceName": "Resource Name 1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"unitPrice": 3.74
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
InvoiceSectionUsageDetailsList-Modern
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234:56789/invoiceSections/98765/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_by_mca_invoice_section.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="providers/Microsoft.Billing/BillingAccounts/1234:56789/invoiceSections/98765",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListByMCAInvoiceSection.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListByMCAInvoiceSection.json
func ExampleUsageDetailsClient_NewListPager_invoiceSectionUsageDetailsListModern() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/BillingAccounts/1234:56789/invoiceSections/98765", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.ModernUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789/invoiceSections/98765/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindModern),
// Properties: &armconsumption.ModernUsageDetailProperties{
// AdditionalInfo: to.Ptr("{ \"UsageType\": \"ComputeHR\", \"ImageType\": \"Windows Client BYOL\", \"ServiceType\": \"Standard_D1\", \"VMName\": null, \"VMProperties\": null, \"VCPUs\": 1, \"CPUs\": 0}"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("1234:56789"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrencyCode: to.Ptr("USD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("2468"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// CustomerName: to.Ptr("Modern Azure Customer 1"),
// CustomerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-30T00:00:00.0000000Z"); return t}()),
// ExchangeRate: to.Ptr("1"),
// ExchangeRateDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-30T00:00:00Z"); return t}()),
// Frequency: to.Ptr("UsageBased"),
// InstanceName: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// InvoiceID: to.Ptr(""),
// InvoiceSectionID: to.Ptr("98765"),
// InvoiceSectionName: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// PartnerEarnedCreditApplied: to.Ptr("0"),
// PartnerName: to.Ptr("Partner Name 1"),
// PartnerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// PreviousInvoiceID: to.Ptr(""),
// PricingCurrencyCode: to.Ptr("USD"),
// Product: to.Ptr("Virtual Machines D Series - D1 - US East"),
// ProductIdentifier: to.Ptr("DZH318Z0BQ4B00FV"),
// ProductOrderID: to.Ptr("a3db7880-70eb-4b4c-6a79-1425a058df5a"),
// ProductOrderName: to.Ptr("Azure plan"),
// PublisherID: to.Ptr(""),
// PublisherName: to.Ptr("Microsoft"),
// PublisherType: to.Ptr("Microsoft"),
// ResellerMpnID: to.Ptr(""),
// ResellerName: to.Ptr("Reseller Name 1"),
// ReservationID: to.Ptr(""),
// ReservationName: to.Ptr(""),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceLocationNormalized: to.Ptr("US East"),
// ServiceInfo1: to.Ptr(""),
// ServiceInfo2: to.Ptr("Windows Client BYOL"),
// ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00Z"); return t}()),
// ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00Z"); return t}()),
// SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// Term: to.Ptr(""),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/providers/Microsoft.Billing/BillingAccounts/1234:56789/invoiceSections/98765/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "modern",
"properties": {
"additionalInfo": "{ \"UsageType\": \"ComputeHR\", \"ImageType\": \"Windows Client BYOL\", \"ServiceType\": \"Standard_D1\", \"VMName\": null, \"VMProperties\": null, \"VCPUs\": 1, \"CPUs\": 0}",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "1234:56789",
"billingAccountName": "Account Name 1",
"billingCurrencyCode": "USD",
"billingPeriodEndDate": "2019-10-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-09-01T00:00:00.0000000Z",
"billingProfileId": "2468",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"costCenter": "DEV",
"costInBillingCurrency": 1.84763819095477,
"costInPricingCurrency": 1.84763819095477,
"costInUSD": 1.84763819095477,
"customerName": "Modern Azure Customer 1",
"customerTenantId": "00000000-0000-0000-0000-000000000000",
"date": "2019-10-30T00:00:00.0000000Z",
"exchangeRate": "1",
"exchangeRateDate": "2019-09-30T00:00:00Z",
"exchangeRatePricingToBilling": 0.077,
"frequency": "UsageBased",
"instanceName": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"invoiceId": "",
"invoiceSectionId": "98765",
"invoiceSectionName": "Invoice Section 1",
"isAzureCreditEligible": false,
"marketPrice": 0.077,
"meterId": "00000000-0000-0000-0000-000000000000",
"partnerEarnedCreditApplied": "0",
"partnerEarnedCreditRate": 0.077,
"partnerName": "Partner Name 1",
"partnerTenantId": "00000000-0000-0000-0000-000000000000",
"paygCostInBillingCurrency": 1.848,
"paygCostInUSD": 1.848,
"previousInvoiceId": "",
"pricingCurrencyCode": "USD",
"product": "Virtual Machines D Series - D1 - US East",
"productIdentifier": "DZH318Z0BQ4B00FV",
"productOrderId": "a3db7880-70eb-4b4c-6a79-1425a058df5a",
"productOrderName": "Azure plan",
"publisherId": "",
"publisherName": "Microsoft",
"publisherType": "Microsoft",
"quantity": 0.7329,
"resellerMpnId": "",
"resellerName": "Reseller Name 1",
"reservationId": "",
"reservationName": "",
"resourceGroup": "Resource Group 1",
"resourceLocation": "USEast",
"resourceLocationNormalized": "US East",
"serviceInfo1": "",
"serviceInfo2": "Windows Client BYOL",
"servicePeriodEndDate": "2019-12-01T00:00:00Z",
"servicePeriodStartDate": "2019-09-01T00:00:00Z",
"subscriptionGuid": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"term": "",
"unitPrice": 4.38
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
ManagementGroupUsageDetailsList-Legacy
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_by_management_group.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="subscriptions/00000000-0000-0000-0000-000000000000",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListByManagementGroup.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListByManagementGroup.json
func ExampleUsageDetailsClient_NewListPager_managementGroupUsageDetailsListLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("Account Name 1"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.0000000Z"); return t}()),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product Name 1"),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceName: to.Ptr("Resource Name 1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id2"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/scope/providers/Microsoft.Billing/billingPeriods/20180801/providers/Microsoft.Consumption/usageDetails/usageDetails_Id2"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("Account Name 1"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Account Name 2"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Account Name 2"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.0000000Z"); return t}()),
// InvoiceSection: to.Ptr("Invoice Section 2"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("11111111-1111-1111-1111-111111111111"),
// OfferID: to.Ptr("Offer Id 2"),
// PartNumber: to.Ptr("Part Number 2"),
// Product: to.Ptr("Product Name 2"),
// ResourceGroup: to.Ptr("Resource Group 2"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 2/providers/Microsoft.Storage/storageAccounts/Resource Name 2"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceName: to.Ptr("Resource Name 2"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "Account Name 1",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Account Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-03-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-03-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"cost": 0.000342194841184,
"costCenter": "DEV",
"date": "2019-03-30T00:00:00.0000000Z",
"effectivePrice": 0.010534556373432,
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product Name 1",
"quantity": 0.8234,
"resourceGroup": "Resource Group 1",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"resourceLocation": "USEast",
"resourceName": "Resource Name 1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"unitPrice": 3.74
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
},
{
"name": "usageDetails_Id2",
"type": "Microsoft.Consumption/usageDetails",
"id": "/scope/providers/Microsoft.Billing/billingPeriods/20180801/providers/Microsoft.Consumption/usageDetails/usageDetails_Id2",
"kind": "legacy",
"properties": {
"accountName": "Account Name 1",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Account Name 2",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-03-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-03-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Account Name 2",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"cost": 0.000295194820065,
"costCenter": "DEV",
"date": "2019-03-30T00:00:00.0000000Z",
"effectivePrice": 0.000402776395232,
"invoiceSection": "Invoice Section 2",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "11111111-1111-1111-1111-111111111111",
"offerId": "Offer Id 2",
"partNumber": "Part Number 2",
"product": "Product Name 2",
"quantity": 0.7329,
"resourceGroup": "Resource Group 2",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 2/providers/Microsoft.Storage/storageAccounts/Resource Name 2",
"resourceLocation": "USEast",
"resourceName": "Resource Name 2",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"unitPrice": 4.38
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
ManagementGroupUsageDetailsListForBillingPeriod-Legacy
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_for_billing_period_by_management_group.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="subscriptions/00000000-0000-0000-0000-000000000000",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListForBillingPeriodByManagementGroup.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListForBillingPeriodByManagementGroup.json
func ExampleUsageDetailsClient_NewListPager_managementGroupUsageDetailsListForBillingPeriodLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("Account Name 1"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.0000000Z"); return t}()),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product Name 1"),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceName: to.Ptr("Resource Name 1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id2"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/scope/providers/Microsoft.Billing/billingPeriods/billingPeriodName/providers/Microsoft.Consumption/usageDetails/usageDetails_Id2"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("Account Name 2"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Account Name 2"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Account Name 2"),
// ChargeType: to.Ptr("UnusedReservation"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.0000000Z"); return t}()),
// InvoiceSection: to.Ptr("Invoice Section 2"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("11111111-1111-1111-1111-111111111111"),
// OfferID: to.Ptr("Offer Id 2"),
// PartNumber: to.Ptr("Part Number 2"),
// Product: to.Ptr("Product Name 2"),
// ResourceGroup: to.Ptr("Resource Group 2"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 2/providers/Microsoft.Storage/storageAccounts/Resource Name 2"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceName: to.Ptr("Resource Name 2"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 2"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "Account Name 1",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Account Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-03-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-03-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"cost": 0.000342194841184,
"costCenter": "DEV",
"date": "2019-03-30T00:00:00.0000000Z",
"effectivePrice": 0.010534556373432,
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product Name 1",
"quantity": 0.8234,
"resourceGroup": "Resource Group 1",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"resourceLocation": "USEast",
"resourceName": "Resource Name 1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"unitPrice": 3.74
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
},
{
"name": "usageDetails_Id2",
"type": "Microsoft.Consumption/usageDetails",
"id": "/scope/providers/Microsoft.Billing/billingPeriods/billingPeriodName/providers/Microsoft.Consumption/usageDetails/usageDetails_Id2",
"kind": "legacy",
"properties": {
"accountName": "Account Name 2",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Account Name 2",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-03-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-03-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Account Name 2",
"chargeType": "UnusedReservation",
"consumedService": "Microsoft.Storage",
"cost": 0.000821821271948,
"costCenter": "DEV",
"date": "2019-03-30T00:00:00.0000000Z",
"effectivePrice": 0.073488920944598,
"invoiceSection": "Invoice Section 2",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "11111111-1111-1111-1111-111111111111",
"offerId": "Offer Id 2",
"partNumber": "Part Number 2",
"product": "Product Name 2",
"quantity": 0.4759,
"resourceGroup": "Resource Group 2",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 2/providers/Microsoft.Storage/storageAccounts/Resource Name 2",
"resourceLocation": "USEast",
"resourceName": "Resource Name 2",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 2",
"unitPrice": 5.74
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
UsageDetailsExpand-Legacy
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01&$expand=meterDetails,additionalInfo&$filter=tags eq 'dev:tools'&$top=1
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_expand.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="subscriptions/00000000-0000-0000-0000-000000000000",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsExpand.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsExpand.json
func ExampleUsageDetailsClient_NewListPager_usageDetailsExpandLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{
Expand: to.Ptr("meterDetails,additionalInfo"),
Filter: to.Ptr("tags eq 'dev:tools'"),
Top: to.Ptr[int32](1)})
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("Account Name 1"),
// AdditionalInfo: to.Ptr("{\"MyType\":\"\",\"ServiceType\":\"\",\"VMName\":\"\",\"UsageType\":\"MyUsage\"}"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.0000000Z"); return t}()),
// Frequency: to.Ptr("UsageBased"),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterDetails: &armconsumption.MeterDetailsResponse{
// MeterCategory: to.Ptr("Networking"),
// MeterName: to.Ptr("Data Transfer Out (GB)"),
// MeterSubCategory: to.Ptr("ExpressRoute"),
// ServiceFamily: to.Ptr("Compute"),
// UnitOfMeasure: to.Ptr("GB"),
// },
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product Name 1"),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceName: to.Ptr("Resource Name 1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "Account Name 1",
"additionalInfo": "{\"MyType\":\"\",\"ServiceType\":\"\",\"VMName\":\"\",\"UsageType\":\"MyUsage\"}",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Account Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-03-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-03-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"cost": 0.000342194841184,
"costCenter": "DEV",
"date": "2019-03-30T00:00:00.0000000Z",
"effectivePrice": 0.010464556322455,
"frequency": "UsageBased",
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": {
"meterCategory": "Networking",
"meterName": "Data Transfer Out (GB)",
"meterSubCategory": "ExpressRoute",
"serviceFamily": "Compute",
"unitOfMeasure": "GB"
},
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product Name 1",
"quantity": 0.8234,
"resourceGroup": "Resource Group 1",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"resourceLocation": "USEast",
"resourceName": "Resource Name 1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"unitPrice": 3.54
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
UsageDetailsList-Legacy
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="subscriptions/00000000-0000-0000-0000-000000000000",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsList.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsList.json
func ExampleUsageDetailsClient_NewListPager_usageDetailsListLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("AccountName"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Customer Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-30T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Customer Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.ClassicStorage"),
// CostCenter: to.Ptr("BAS"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-09T00:00:00.0000000Z"); return t}()),
// Frequency: to.Ptr("UsageBased"),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product1"),
// ResourceGroup: to.Ptr("Resource-Group-westus"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource-Group-westus/providers/Microsoft.ClassicStorage/storageAccounts/ResourceName1"),
// ResourceLocation: to.Ptr("uswest"),
// ResourceName: to.Ptr("ResourceName1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("SubscriptionName 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "AccountName",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Customer Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-04-30T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-04-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Customer Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.ClassicStorage",
"cost": 1.980949998E-06,
"costCenter": "BAS",
"date": "2019-04-09T00:00:00.0000000Z",
"effectivePrice": 0.054693034210767,
"frequency": "UsageBased",
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product1",
"quantity": 3.6E-05,
"resourceGroup": "Resource-Group-westus",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource-Group-westus/providers/Microsoft.ClassicStorage/storageAccounts/ResourceName1",
"resourceLocation": "uswest",
"resourceName": "ResourceName1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "SubscriptionName 1",
"unitPrice": 5.47
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
UsageDetailsListByMetricActualCost-Legacy
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01&metric=actualcost
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_by_metric_actual_cost.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="subscriptions/00000000-0000-0000-0000-000000000000",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListByMetricActualCost.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListByMetricActualCost.json
func ExampleUsageDetailsClient_NewListPager_usageDetailsListByMetricActualCostLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{
Metric: to.Ptr(armconsumption.MetrictypeActualCostMetricType)})
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("AccountName"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Customer Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-30T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Customer Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.ClassicStorage"),
// CostCenter: to.Ptr("BAS"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-09T00:00:00.0000000Z"); return t}()),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product1"),
// ResourceGroup: to.Ptr("Resource-Group-westus"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource-Group-westus/providers/Microsoft.ClassicStorage/storageAccounts/ResourceName1"),
// ResourceLocation: to.Ptr("uswest"),
// ResourceName: to.Ptr("ResourceName1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("SubscriptionName 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "AccountName",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Customer Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-04-30T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-04-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Customer Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.ClassicStorage",
"cost": 1.968949998E-06,
"costCenter": "BAS",
"date": "2019-04-09T00:00:00.0000000Z",
"effectivePrice": 0.054693055510767,
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product1",
"quantity": 3.6E-05,
"resourceGroup": "Resource-Group-westus",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource-Group-westus/providers/Microsoft.ClassicStorage/storageAccounts/ResourceName1",
"resourceLocation": "uswest",
"resourceName": "ResourceName1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "SubscriptionName 1",
"unitPrice": 5.47
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
UsageDetailsListByMetricAmortizedCost-Legacy
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01&metric=amortizedcost
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_by_metric_amortized_cost.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="subscriptions/00000000-0000-0000-0000-000000000000",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListByMetricAmortizedCost.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListByMetricAmortizedCost.json
func ExampleUsageDetailsClient_NewListPager_usageDetailsListByMetricAmortizedCostLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{
Metric: to.Ptr(armconsumption.MetrictypeAmortizedCostMetricType)})
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("AccountName"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Customer Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-30T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Customer Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.ClassicStorage"),
// CostCenter: to.Ptr("BAS"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-09T00:00:00.0000000Z"); return t}()),
// Frequency: to.Ptr("UsageBased"),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product1"),
// ResourceGroup: to.Ptr("Resource-Group-westus"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource-Group-westus/providers/Microsoft.ClassicStorage/storageAccounts/ResourceName1"),
// ResourceLocation: to.Ptr("uswest"),
// ResourceName: to.Ptr("ResourceName1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("SubscriptionName 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "AccountName",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Customer Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-04-30T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-04-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Customer Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.ClassicStorage",
"cost": 1.968949998E-06,
"costCenter": "BAS",
"date": "2019-04-09T00:00:00.0000000Z",
"effectivePrice": 0.054693055510767,
"frequency": "UsageBased",
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product1",
"quantity": 3.6E-05,
"resourceGroup": "Resource-Group-westus",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource-Group-westus/providers/Microsoft.ClassicStorage/storageAccounts/ResourceName1",
"resourceLocation": "uswest",
"resourceName": "ResourceName1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "SubscriptionName 1",
"unitPrice": 5.47
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
UsageDetailsListByMetricUsage-Legacy
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01&metric=usage
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_by_metric_usage.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="subscriptions/00000000-0000-0000-0000-000000000000",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListByMetricUsage.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListByMetricUsage.json
func ExampleUsageDetailsClient_NewListPager_usageDetailsListByMetricUsageLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{
Metric: to.Ptr(armconsumption.MetrictypeUsageMetricType)})
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("AccountName"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Customer Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-30T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Customer Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.ClassicStorage"),
// CostCenter: to.Ptr("BAS"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-09T00:00:00.0000000Z"); return t}()),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product1"),
// ResourceGroup: to.Ptr("Resource-Group-westus"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource-Group-westus/providers/Microsoft.ClassicStorage/storageAccounts/ResourceName1"),
// ResourceLocation: to.Ptr("uswest"),
// ResourceName: to.Ptr("ResourceName1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("SubscriptionName 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "AccountName",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Customer Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-04-30T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-04-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Customer Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.ClassicStorage",
"cost": 1.968949998E-06,
"costCenter": "BAS",
"date": "2019-04-09T00:00:00.0000000Z",
"effectivePrice": 0.054693055510767,
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product1",
"quantity": 3.6E-05,
"resourceGroup": "Resource-Group-westus",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource-Group-westus/providers/Microsoft.ClassicStorage/storageAccounts/ResourceName1",
"resourceLocation": "uswest",
"resourceName": "ResourceName1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "SubscriptionName 1",
"unitPrice": 5.47
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
UsageDetailsListFilterByTag-Legacy
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01&$filter=tags eq 'dev:tools'
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_filter_by_tag.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="subscriptions/00000000-0000-0000-0000-000000000000",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListFilterByTag.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListFilterByTag.json
func ExampleUsageDetailsClient_NewListPager_usageDetailsListFilterByTagLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{
Filter: to.Ptr("tags eq 'dev:tools'")})
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("Account Name 1"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.0000000Z"); return t}()),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product Name 1"),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceName: to.Ptr("Resource Name 1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "Account Name 1",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Account Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-03-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-03-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"cost": 0.000342194841184,
"costCenter": "DEV",
"date": "2019-03-30T00:00:00.0000000Z",
"effectivePrice": 0.010534556373432,
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product Name 1",
"quantity": 0.8234,
"resourceGroup": "Resource Group 1",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"resourceLocation": "USEast",
"resourceName": "Resource Name 1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"unitPrice": 3.74
},
"tags": {
"dev": "tools"
}
}
]
}
UsageDetailsListForBillingPeriod-Legacy
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python usage_details_list_for_billing_period.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.usage_details.list(
scope="subscriptions/00000000-0000-0000-0000-000000000000",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/UsageDetailsListForBillingPeriod.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/UsageDetailsListForBillingPeriod.json
func ExampleUsageDetailsClient_NewListPager_usageDetailsListForBillingPeriodLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.UsageDetailsClientListResponse{
// UsageDetailsListResult: armconsumption.UsageDetailsListResult{
// Value: []armconsumption.UsageDetailClassification{
// &armconsumption.LegacyUsageDetail{
// Name: to.Ptr("usageDetails_Id1"),
// Type: to.Ptr("Microsoft.Consumption/usageDetails"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"),
// Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy),
// Properties: &armconsumption.LegacyUsageDetailProperties{
// AccountName: to.Ptr("Account Name 1"),
// BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"),
// BillingAccountID: to.Ptr("xxxxxxxx"),
// BillingAccountName: to.Ptr("Account Name 1"),
// BillingCurrency: to.Ptr("CAD"),
// BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.0000000Z"); return t}()),
// BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.0000000Z"); return t}()),
// BillingProfileID: to.Ptr("xxxxxxxx"),
// BillingProfileName: to.Ptr("Account Name 1"),
// ChargeType: to.Ptr("Usage"),
// ConsumedService: to.Ptr("Microsoft.Storage"),
// CostCenter: to.Ptr("DEV"),
// Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.0000000Z"); return t}()),
// InvoiceSection: to.Ptr("Invoice Section 1"),
// IsAzureCreditEligible: to.Ptr(false),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// OfferID: to.Ptr("Offer Id 1"),
// PartNumber: to.Ptr("Part Number 1"),
// Product: to.Ptr("Product Name 1"),
// ResourceGroup: to.Ptr("Resource Group 1"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"),
// ResourceLocation: to.Ptr("USEast"),
// ResourceName: to.Ptr("Resource Name 1"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// SubscriptionName: to.Ptr("Subscription Name 1"),
// },
// Tags: map[string]*string{
// "dev": to.Ptr("tools"),
// "env": to.Ptr("newcrp"),
// },
// },
// },
// },
// }
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "usageDetails_Id1",
"type": "Microsoft.Consumption/usageDetails",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1",
"kind": "legacy",
"properties": {
"accountName": "Account Name 1",
"benefitId": "00000000-0000-0000-0000-000000000000",
"benefitName": "Reservation_purchase_03-09-2018_10-59",
"billingAccountId": "xxxxxxxx",
"billingAccountName": "Account Name 1",
"billingCurrency": "CAD",
"billingPeriodEndDate": "2019-03-31T00:00:00.0000000Z",
"billingPeriodStartDate": "2019-03-01T00:00:00.0000000Z",
"billingProfileId": "xxxxxxxx",
"billingProfileName": "Account Name 1",
"chargeType": "Usage",
"consumedService": "Microsoft.Storage",
"cost": 0.000342194841184,
"costCenter": "DEV",
"date": "2019-03-30T00:00:00.0000000Z",
"effectivePrice": 0.010534556373432,
"invoiceSection": "Invoice Section 1",
"isAzureCreditEligible": false,
"meterDetails": null,
"meterId": "00000000-0000-0000-0000-000000000000",
"offerId": "Offer Id 1",
"partNumber": "Part Number 1",
"product": "Product Name 1",
"quantity": 0.8234,
"resourceGroup": "Resource Group 1",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1",
"resourceLocation": "USEast",
"resourceName": "Resource Name 1",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"subscriptionName": "Subscription Name 1",
"unitPrice": 3.74
},
"tags": {
"dev": "tools",
"env": "newcrp"
}
}
]
}
Definitions
createdByType
Enumeration
The type of identity that created the resource.
| Value |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
ErrorAdditionalInfo
Object
The resource management error additional info.
| Name |
Type |
Description |
|
info
|
object
|
The additional info.
|
|
type
|
string
|
The additional info type.
|
ErrorDetail
Object
The error detail.
| Name |
Type |
Description |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
The error additional info.
|
|
code
|
string
|
The error code.
|
|
details
|
ErrorDetail[]
|
The error details.
|
|
message
|
string
|
The error message.
|
|
target
|
string
|
The error target.
|
ErrorResponse
Object
Error response
| Name |
Type |
Description |
|
error
|
ErrorDetail
|
The error object.
|
LegacyUsageDetail
Object
Legacy usage detail.
| Name |
Type |
Description |
|
etag
|
string
|
The etag for the resource.
|
|
id
|
string
|
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
kind
|
string:
legacy
|
Specifies the kind of usage details.
|
|
name
|
string
|
The name of the resource
|
|
properties.accountName
|
string
|
Account Name.
|
|
properties.accountOwnerId
|
string
|
Account Owner Id.
|
|
properties.additionalInfo
|
string
|
Additional details of this usage item. By default this is not populated, unless it's specified in $expand. Use this field to get usage line item specific details such as the actual VM Size (ServiceType) or the ratio in which the reservation discount is applied.
|
|
properties.benefitId
|
string
|
Unique identifier for the applicable benefit.
|
|
properties.benefitName
|
string
|
Name of the applicable benefit.
|
|
properties.billingAccountId
|
string
|
Billing Account identifier.
|
|
properties.billingAccountName
|
string
|
Billing Account Name.
|
|
properties.billingCurrency
|
string
|
Billing Currency.
|
|
properties.billingPeriodEndDate
|
string
(date-time)
|
The billing period end date.
|
|
properties.billingPeriodStartDate
|
string
(date-time)
|
The billing period start date.
|
|
properties.billingProfileId
|
string
|
Billing Profile identifier.
|
|
properties.billingProfileName
|
string
|
Billing Profile Name.
|
|
properties.chargeType
|
string
|
Indicates a charge represents credits, usage, a Marketplace purchase, a reservation fee, or a refund.
|
|
properties.consumedService
|
string
|
Consumed service name. Name of the azure resource provider that emits the usage or was purchased. This value is not provided for marketplace usage.
|
|
properties.cost
|
number
(decimal)
|
The amount of cost before tax.
|
|
properties.costCenter
|
string
|
The cost center of this department if it is a department and a cost center is provided.
|
|
properties.date
|
string
(date-time)
|
Date for the usage record.
|
|
properties.effectivePrice
|
number
(decimal)
|
Effective Price that's charged for the usage.
|
|
properties.frequency
|
string
|
Indicates how frequently this charge will occur. OneTime for purchases which only happen once, Monthly for fees which recur every month, and UsageBased for charges based on how much a service is used.
|
|
properties.invoiceSection
|
string
|
Invoice Section Name.
|
|
properties.isAzureCreditEligible
|
boolean
|
Is Azure Credit Eligible.
|
|
properties.meterDetails
|
MeterDetailsResponse
|
The details about the meter. By default this is not populated, unless it's specified in $expand.
|
|
properties.meterId
|
string
(uuid)
|
The meter id (GUID). Not available for marketplace. For reserved instance this represents the primary meter for which the reservation was purchased. For the actual VM Size for which the reservation is purchased see productOrderName.
|
|
properties.offerId
|
string
|
Offer Id. Ex: MS-AZR-0017P, MS-AZR-0148P.
|
|
properties.partNumber
|
string
|
Part Number of the service used. Can be used to join with the price sheet. Not available for marketplace.
|
|
properties.payGPrice
|
number
(decimal)
|
Retail price for the resource.
|
|
properties.planName
|
string
|
Plan Name.
|
|
properties.pricingModel
|
PricingModelType
|
Identifier that indicates how the meter is priced.
|
|
properties.product
|
string
|
Product name for the consumed service or purchase. Not available for Marketplace.
|
|
properties.productOrderId
|
string
|
Product Order Id. For reservations this is the Reservation Order ID.
|
|
properties.productOrderName
|
string
|
Product Order Name. For reservations this is the SKU that was purchased.
|
|
properties.publisherName
|
string
|
Publisher Name.
|
|
properties.publisherType
|
string
|
Publisher Type.
|
|
properties.quantity
|
number
(decimal)
|
The usage quantity.
|
|
properties.reservationId
|
string
|
ARM resource id of the reservation. Only applies to records relevant to reservations.
|
|
properties.reservationName
|
string
|
User provided display name of the reservation. Last known name for a particular day is populated in the daily data. Only applies to records relevant to reservations.
|
|
properties.resourceGroup
|
string
|
Resource Group Name.
|
|
properties.resourceId
|
string
|
Unique identifier of the Azure Resource Manager usage detail resource.
|
|
properties.resourceLocation
|
string
|
Resource Location.
|
|
properties.resourceName
|
string
|
Resource Name.
|
|
properties.serviceInfo1
|
string
|
Service-specific metadata.
|
|
properties.serviceInfo2
|
string
|
Legacy field with optional service-specific metadata.
|
|
properties.subscriptionId
|
string
|
Subscription guid.
|
|
properties.subscriptionName
|
string
|
Subscription name.
|
|
properties.term
|
string
|
Term (in months). 1 month for monthly recurring purchase. 12 months for a 1 year reservation. 36 months for a 3 year reservation.
|
|
properties.unitPrice
|
number
(decimal)
|
Unit Price is the price applicable to you. (your EA or other contract price).
|
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
|
tags
|
object
|
Resource tags.
|
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
MeterDetailsResponse
Object
The properties of the meter detail.
| Name |
Type |
Description |
|
meterCategory
|
string
|
The category of the meter, for example, 'Cloud services', 'Networking', etc..
|
|
meterName
|
string
|
The name of the meter, within the given meter category
|
|
meterSubCategory
|
string
|
The subcategory of the meter, for example, 'A6 Cloud services', 'ExpressRoute (IXP)', etc..
|
|
serviceFamily
|
string
|
The service family.
|
|
unitOfMeasure
|
string
|
The unit in which the meter consumption is charged, for example, 'Hours', 'GB', etc.
|
Metrictype
Enumeration
| Value |
Description |
|
actualcost
|
Actual cost data.
|
|
amortizedcost
|
Amortized cost data.
|
|
usage
|
Usage data.
|
ModernUsageDetail
Object
Modern usage detail.
| Name |
Type |
Description |
|
etag
|
string
|
The etag for the resource.
|
|
id
|
string
|
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
kind
|
string:
modern
|
Specifies the kind of usage details.
|
|
name
|
string
|
The name of the resource
|
|
properties.additionalInfo
|
string
|
Additional details of this usage item. Use this field to get usage line item specific details such as the actual VM Size (ServiceType) or the ratio in which the reservation discount is applied.
|
|
properties.benefitId
|
string
|
Unique identifier for the applicable benefit.
|
|
properties.benefitName
|
string
|
Name of the applicable benefit.
|
|
properties.billingAccountId
|
string
|
Billing Account identifier.
|
|
properties.billingAccountName
|
string
|
Name of the Billing Account.
|
|
properties.billingCurrencyCode
|
string
|
The currency defining the billed cost.
|
|
properties.billingPeriodEndDate
|
string
(date-time)
|
Billing Period End Date as in the invoice.
|
|
properties.billingPeriodStartDate
|
string
(date-time)
|
Billing Period Start Date as in the invoice.
|
|
properties.billingProfileId
|
string
|
Identifier for the billing profile that groups costs across invoices in the a singular billing currency across across the customers who have onboarded the Microsoft customer agreement and the customers in CSP who have made entitlement purchases like SaaS, Marketplace, RI, etc.
|
|
properties.billingProfileName
|
string
|
Name of the billing profile that groups costs across invoices in the a singular billing currency across across the customers who have onboarded the Microsoft customer agreement and the customers in CSP who have made entitlement purchases like SaaS, Marketplace, RI, etc.
|
|
properties.chargeType
|
string
|
Indicates a charge represents credits, usage, a Marketplace purchase, a reservation fee, or a refund.
|
|
properties.consumedService
|
string
|
Consumed service name. Name of the azure resource provider that emits the usage or was purchased. This value is not provided for marketplace usage.
|
|
properties.costAllocationRuleName
|
string
|
Name for Cost Allocation Rule.
|
|
properties.costCenter
|
string
|
The cost center of this department if it is a department and a cost center is provided.
|
|
properties.costInBillingCurrency
|
number
(decimal)
|
ExtendedCost or blended cost before tax in billed currency.
|
|
properties.costInPricingCurrency
|
number
(decimal)
|
ExtendedCost or blended cost before tax in pricing currency to correlate with prices.
|
|
properties.costInUSD
|
number
(decimal)
|
Estimated extendedCost or blended cost before tax in USD.
|
|
properties.customerName
|
string
|
Name of the customer's AAD tenant.
|
|
properties.customerTenantId
|
string
|
Identifier of the customer's AAD tenant.
|
|
properties.date
|
string
(date-time)
|
Date for the usage record.
|
|
properties.effectivePrice
|
number
(decimal)
|
Effective Price that's charged for the usage.
|
|
properties.exchangeRate
|
string
|
Exchange rate used in conversion from pricing currency to billing currency.
|
|
properties.exchangeRateDate
|
string
(date-time)
|
Date on which exchange rate used in conversion from pricing currency to billing currency.
|
|
properties.exchangeRatePricingToBilling
|
number
(decimal)
|
Exchange Rate from pricing currency to billing currency.
|
|
properties.frequency
|
string
|
Indicates how frequently this charge will occur. OneTime for purchases which only happen once, Monthly for fees which recur every month, and UsageBased for charges based on how much a service is used.
|
|
properties.instanceName
|
string
|
Instance Name.
|
|
properties.invoiceId
|
string
|
Invoice ID as on the invoice where the specific transaction appears.
|
|
properties.invoiceSectionId
|
string
|
Identifier of the project that is being charged in the invoice. Not applicable for Microsoft Customer Agreements onboarded by partners.
|
|
properties.invoiceSectionName
|
string
|
Name of the project that is being charged in the invoice. Not applicable for Microsoft Customer Agreements onboarded by partners.
|
|
properties.isAzureCreditEligible
|
boolean
|
Determines if the cost is eligible to be paid for using Azure credits.
|
|
properties.marketPrice
|
number
(decimal)
|
Market Price that's charged for the usage.
|
|
properties.meterCategory
|
string
|
Identifies the top-level service for the usage.
|
|
properties.meterId
|
string
(uuid)
|
The meter id (GUID). Not available for marketplace. For reserved instance this represents the primary meter for which the reservation was purchased. For the actual VM Size for which the reservation is purchased see productOrderName.
|
|
properties.meterName
|
string
|
Identifies the name of the meter against which consumption is measured.
|
|
properties.meterRegion
|
string
|
Identifies the location of the datacenter for certain services that are priced based on datacenter location.
|
|
properties.meterSubCategory
|
string
|
Defines the type or sub-category of Azure service that can affect the rate.
|
|
properties.partnerEarnedCreditApplied
|
string
|
Flag to indicate if partner earned credit has been applied or not.
|
|
properties.partnerEarnedCreditRate
|
number
(decimal)
|
Rate of discount applied if there is a partner earned credit (PEC) based on partner admin link access.
|
|
properties.partnerName
|
string
|
Name of the partner' AAD tenant.
|
|
properties.partnerTenantId
|
string
|
Identifier for the partner's AAD tenant.
|
|
properties.payGPrice
|
number
(decimal)
|
Retail price for the resource.
|
|
properties.paygCostInBillingCurrency
|
number
(decimal)
|
The amount of PayG cost before tax in billing currency.
|
|
properties.paygCostInUSD
|
number
(decimal)
|
The amount of PayG cost before tax in US Dollar currency.
|
|
properties.previousInvoiceId
|
string
|
Reference to an original invoice there is a refund (negative cost). This is populated only when there is a refund.
|
|
properties.pricingCurrencyCode
|
string
|
Pricing Billing Currency.
|
|
properties.pricingModel
|
PricingModelType
|
Identifier that indicates how the meter is priced
|
|
properties.product
|
string
|
Name of the product that has accrued charges by consumption or purchase as listed in the invoice. Not available for Marketplace.
|
|
properties.productIdentifier
|
string
|
Identifier for the product that has accrued charges by consumption or purchase . This is the concatenated key of productId and SkuId in partner center.
|
|
properties.productOrderId
|
string
|
The identifier for the asset or Azure plan name that the subscription belongs to. For example: Azure Plan. For reservations this is the Reservation Order ID.
|
|
properties.productOrderName
|
string
|
Product Order Name. For reservations this is the SKU that was purchased.
|
|
properties.provider
|
string
|
Identifier for Product Category or Line Of Business, Ex - Azure, Microsoft 365, AWS e.t.c
|
|
properties.publisherId
|
string
|
Publisher Id.
|
|
properties.publisherName
|
string
|
Name of the publisher of the service including Microsoft or Third Party publishers.
|
|
properties.publisherType
|
string
|
Type of publisher that identifies if the publisher is first party, third party reseller or third party agency.
|
|
properties.quantity
|
number
(decimal)
|
Measure the quantity purchased or consumed.The amount of the meter used during the billing period.
|
|
properties.resellerMpnId
|
string
|
MPNId for the reseller associated with the subscription.
|
|
properties.resellerName
|
string
|
Reseller Name.
|
|
properties.reservationId
|
string
|
ARM resource id of the reservation. Only applies to records relevant to reservations.
|
|
properties.reservationName
|
string
|
User provided display name of the reservation. Last known name for a particular day is populated in the daily data. Only applies to records relevant to reservations.
|
|
properties.resourceGroup
|
string
|
Name of the Azure resource group used for cohesive lifecycle management of resources.
|
|
properties.resourceLocation
|
string
|
Name of the resource location.
|
|
properties.resourceLocationNormalized
|
string
|
Resource Location Normalized.
|
|
properties.serviceFamily
|
string
|
List the service family for the product purchased or charged (Example: Storage ; Compute).
|
|
properties.serviceInfo1
|
string
|
Service-specific metadata.
|
|
properties.serviceInfo2
|
string
|
Legacy field with optional service-specific metadata.
|
|
properties.servicePeriodEndDate
|
string
(date-time)
|
End date for the period when the service usage was rated for charges. The prices for Azure services are determined based on the rating period.
|
|
properties.servicePeriodStartDate
|
string
(date-time)
|
Start date for the rating period when the service usage was rated for charges. The prices for Azure services are determined for the rating period.
|
|
properties.subscriptionGuid
|
string
|
Unique Microsoft generated identifier for the Azure Subscription.
|
|
properties.subscriptionName
|
string
|
Name of the Azure Subscription.
|
|
properties.term
|
string
|
Term (in months). Displays the term for the validity of the offer. For example. In case of reserved instances it displays 12 months for yearly term of reserved instance. For one time purchases or recurring purchases, the terms displays 1 month; This is not applicable for Azure consumption.
|
|
properties.unitOfMeasure
|
string
|
Identifies the Unit that the service is charged in. For example, GB, hours, 10,000 s.
|
|
properties.unitPrice
|
number
(decimal)
|
Unit Price is the price applicable to you. (your EA or other contract price).
|
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
|
tags
|
object
|
Resource tags.
|
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
PricingModelType
Enumeration
Identifier that indicates how the meter is priced.
| Value |
Description |
|
On Demand
|
|
|
Reservation
|
|
|
Spot
|
|
systemData
Object
Metadata pertaining to creation and last modification of the resource.
| Name |
Type |
Description |
|
createdAt
|
string
(date-time)
|
The timestamp of resource creation (UTC).
|
|
createdBy
|
string
|
The identity that created the resource.
|
|
createdByType
|
createdByType
|
The type of identity that created the resource.
|
|
lastModifiedAt
|
string
(date-time)
|
The timestamp of resource last modification (UTC)
|
|
lastModifiedBy
|
string
|
The identity that last modified the resource.
|
|
lastModifiedByType
|
createdByType
|
The type of identity that last modified the resource.
|
UsageDetailsKind
Enumeration
Specifies the kind of usage details.
| Value |
Description |
|
legacy
|
|
|
modern
|
|
UsageDetailsListResult
Object
Result of listing usage details. It contains a list of available usage details in reverse chronological order by billing period.
| Name |
Type |
Description |
|
nextLink
|
string
|
The link (url) to the next page of results.
|
|
value
|
UsageDetail[]:
|
The list of usage details.
|