Visar en lista med användningsinformation för det definierade omfånget. Användningsinformation är endast tillgänglig via det här API:et för 1 maj 2014 eller senare.
Obs! Microsoft kommer att dra tillbaka API:et för förbrukningsinformation någon gång i framtiden. Vi rekommenderar inte att du använder ett nytt beroende av det här API:et. Använd API:et för kostnadsinformation i stället. Vi meddelar kunderna när ett datum för pensionering har fastställts. Mer information finns i Generera kostnadsinformationsrapport – Skapa åtgärd
GET https://management.azure.com/{scope}/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
Med valfria parametrar:
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-parametrar
| Name |
I |
Obligatorisk |
Typ |
Description |
|
scope
|
path |
True
|
string
|
Resursens fullständigt kvalificerade Azure Resource Manager-identifierare.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
Den API-version som ska användas för den här åtgärden.
|
|
$expand
|
query |
|
string
|
Kan användas för att expandera egenskaper/additionalInfo eller egenskaper/meterDetails i en lista med användningsinformation. Som standard inkluderas inte dessa fält när du listar användningsinformation.
|
|
$filter
|
query |
|
string
|
Kan användas för att filtrera usageDetails efter egenskaper/resourceGroup, properties/resourceName, properties/resourceId, properties/chargeType, properties/reservationId, properties/publisherType eller tags. Filtret stöder "eq", "lt", "gt", "le", "ge" och "and". Det stöder för närvarande inte "ne", "eller" eller "inte". Taggfilter är en nyckelvärdeparsträng där nyckel och värde avgränsas med ett kolon (:). PublisherType-filtret accepterar två värden i Azure och Marketplace och stöds för närvarande för webbdirigeringserbjudandetyp
|
|
$skiptoken
|
query |
|
string
|
Skiptoken används endast om en tidigare åtgärd returnerade ett partiellt resultat. Om ett tidigare svar innehåller ett nextLink-element innehåller värdet för nextLink-elementet en skiptoken-parameter som anger en startpunkt som ska användas för efterföljande anrop.
|
|
$top
|
query |
|
integer
(int32)
minimum: 1 maximum: 1000
|
Kan användas för att begränsa antalet resultat till den senaste N-användningenDetails.
|
|
metric
|
query |
|
Metrictype
|
Tillåter att du väljer olika typer av kostnads-/användningsposter.
|
Svar
Säkerhet
azure_auth
Azure Active Directory OAuth2-flöde.
Typ:
oauth2
Flow:
implicit
Auktoriseringswebbadress:
https://login.microsoftonline.com/common/oauth2/authorize
Omfattningar
| Name |
Description |
|
user_impersonation
|
personifiera ditt användarkonto
|
Exempel
BillingAccountUsageDetailsList-Legacy
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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
Exempelbegäran
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
Exempelsvar
{
"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"
}
}
]
}
Definitioner
createdByType
Uppräkning
Den typ av identitet som skapade resursen.
| Värde |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
ErrorAdditionalInfo
Objekt
Ytterligare information om resurshanteringsfelet.
| Name |
Typ |
Description |
|
info
|
object
|
Ytterligare information.
|
|
type
|
string
|
Ytterligare informationstyp.
|
ErrorDetail
Objekt
Felinformationen.
| Name |
Typ |
Description |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
Ytterligare information om felet.
|
|
code
|
string
|
Felkoden.
|
|
details
|
ErrorDetail[]
|
Felinformationen.
|
|
message
|
string
|
Felmeddelandet.
|
|
target
|
string
|
Felmålet.
|
ErrorResponse
Objekt
Felsvar
LegacyUsageDetail
Objekt
Äldre användningsinformation.
| Name |
Typ |
Description |
|
etag
|
string
|
Etag för resursen.
|
|
id
|
string
|
Fullständigt kvalificerat resurs-ID för resursen. Ex – /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
kind
|
string:
legacy
|
Anger typen av användningsinformation.
|
|
name
|
string
|
Namnet på resursen
|
|
properties.accountName
|
string
|
Kontonamn.
|
|
properties.accountOwnerId
|
string
|
Kontoägar-ID.
|
|
properties.additionalInfo
|
string
|
Ytterligare information om det här användningsobjektet. Som standard fylls detta inte i, såvida det inte anges i $expand. Använd det här fältet för att hämta specifik information om användningsradsobjekt, till exempel den faktiska VM-storleken (ServiceType) eller förhållandet där reservationsrabatten tillämpas.
|
|
properties.benefitId
|
string
|
Unik identifierare för den tillämpliga förmånen.
|
|
properties.benefitName
|
string
|
Namnet på den tillämpliga förmånen.
|
|
properties.billingAccountId
|
string
|
Identifierare för faktureringskonto.
|
|
properties.billingAccountName
|
string
|
Namn på faktureringskonto.
|
|
properties.billingCurrency
|
string
|
Faktureringsvaluta.
|
|
properties.billingPeriodEndDate
|
string
(date-time)
|
Slutdatum för faktureringsperiod.
|
|
properties.billingPeriodStartDate
|
string
(date-time)
|
Startdatum för faktureringsperiod.
|
|
properties.billingProfileId
|
string
|
Identifierare för faktureringsprofil.
|
|
properties.billingProfileName
|
string
|
Namn på faktureringsprofil.
|
|
properties.chargeType
|
string
|
Anger att en avgift representerar krediter, användning, ett Marketplace-köp, en reservationsavgift eller en återbetalning.
|
|
properties.consumedService
|
string
|
Namn på förbrukad tjänst. Namnet på azure-resursprovidern som genererar användningen eller som har köpts. Det här värdet anges inte för marketplace-användning.
|
|
properties.cost
|
number
(decimal)
|
Kostnaden före skatt.
|
|
properties.costCenter
|
string
|
Kostnadsställe för den här avdelningen om det är en avdelning och ett kostnadsställe tillhandahålls.
|
|
properties.date
|
string
(date-time)
|
Datum för användningsposten.
|
|
properties.effectivePrice
|
number
(decimal)
|
Effektivt pris som debiteras för användningen.
|
|
properties.frequency
|
string
|
Anger hur ofta den här avgiften ska ske. OneTime för köp som bara sker en gång, Månadsvis för avgifter som återkommer varje månad och UsageBased för avgifter baserat på hur mycket en tjänst används.
|
|
properties.invoiceSection
|
string
|
Namn på fakturaavsnitt.
|
|
properties.isAzureCreditEligible
|
boolean
|
Är Azure-kredit berättigad.
|
|
properties.meterDetails
|
MeterDetailsResponse
|
Information om mätaren. Som standard fylls detta inte i, såvida det inte anges i $expand.
|
|
properties.meterId
|
string
(uuid)
|
Mätar-ID (GUID). Inte tillgängligt för Marketplace. För reserverad instans representerar detta den primära mätaren som reservationen köptes för. För den faktiska VM-storlek som reservationen har köpts för, se productOrderName.
|
|
properties.offerId
|
string
|
Erbjudande-ID. T.ex. MS-AZR-0017P, MS-AZR-0148P.
|
|
properties.partNumber
|
string
|
Delnummer för den tjänst som används. Kan användas för att ansluta till prisdokumentet. Inte tillgängligt för Marketplace.
|
|
properties.payGPrice
|
number
(decimal)
|
Detaljhandelspris för resursen.
|
|
properties.planName
|
string
|
Plannamn.
|
|
properties.pricingModel
|
PricingModelType
|
Identifierare som anger hur mätaren prissätts.
|
|
properties.product
|
string
|
Produktnamn för den förbrukade tjänsten eller köpet. Inte tillgängligt för Marketplace.
|
|
properties.productOrderId
|
string
|
Produktorder-ID. För reservationer är detta reservationsbeställnings-ID.
|
|
properties.productOrderName
|
string
|
Produktordernamn. För reservationer är detta den SKU som köptes.
|
|
properties.publisherName
|
string
|
Utgivarens namn.
|
|
properties.publisherType
|
string
|
Utgivartyp.
|
|
properties.quantity
|
number
(decimal)
|
Användningskvantiteten.
|
|
properties.reservationId
|
string
|
ARM-resurs-ID för reservationen. Gäller endast poster som är relevanta för reservationer.
|
|
properties.reservationName
|
string
|
Användaren angav visningsnamnet för reservationen. Det senast kända namnet för en viss dag fylls i i de dagliga data. Gäller endast poster som är relevanta för reservationer.
|
|
properties.resourceGroup
|
string
|
Namn på resursgrupp.
|
|
properties.resourceId
|
string
|
Unik identifierare för resursen för Användningsinformation för Azure Resource Manager.
|
|
properties.resourceLocation
|
string
|
Resursplats.
|
|
properties.resourceName
|
string
|
Resursnamn.
|
|
properties.serviceInfo1
|
string
|
Tjänstspecifika metadata.
|
|
properties.serviceInfo2
|
string
|
Äldre fält med valfria tjänstspecifika metadata.
|
|
properties.subscriptionId
|
string
|
Prenumerations-GUID.
|
|
properties.subscriptionName
|
string
|
Prenumerationsnamn.
|
|
properties.term
|
string
|
Term (i månader). 1 månad för månadsvis återkommande köp. 12 månader för en 1 års reservation. 36 månader för en 3 års reservation.
|
|
properties.unitPrice
|
number
(decimal)
|
Enhetspris är det pris som gäller för dig. (ditt EA eller annat kontraktspris).
|
|
systemData
|
systemData
|
Azure Resource Manager-metadata som innehåller createdBy och modifiedBy information.
|
|
tags
|
object
|
Resurstaggar.
|
|
type
|
string
|
Resurstypen. Till exempel "Microsoft.Compute/virtualMachines" eller "Microsoft.Storage/storageAccounts"
|
MeterDetailsResponse
Objekt
Egenskaperna för mätarinformationen.
| Name |
Typ |
Description |
|
meterCategory
|
string
|
Mätarens kategori, till exempel "Molntjänster", "Nätverk" osv..
|
|
meterName
|
string
|
Mätarens namn inom den angivna mätarkategorin
|
|
meterSubCategory
|
string
|
Underkategorin för mätaren, till exempel "A6 Cloud Services", "ExpressRoute (IXP)" osv..
|
|
serviceFamily
|
string
|
Servicefamiljen.
|
|
unitOfMeasure
|
string
|
Den enhet där mätarförbrukningen debiteras, till exempel "Timmar", "GB" osv.
|
Metrictype
Uppräkning
| Värde |
Description |
|
actualcost
|
Faktiska kostnadsdata.
|
|
amortizedcost
|
Amorterade kostnadsdata.
|
|
usage
|
Användningsdata.
|
ModernUsageDetail
Objekt
Modern användningsinformation.
| Name |
Typ |
Description |
|
etag
|
string
|
Etag för resursen.
|
|
id
|
string
|
Fullständigt kvalificerat resurs-ID för resursen. Ex – /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
kind
|
string:
modern
|
Anger typen av användningsinformation.
|
|
name
|
string
|
Namnet på resursen
|
|
properties.additionalInfo
|
string
|
Ytterligare information om det här användningsobjektet. Använd det här fältet för att hämta specifik information om användningsradsobjekt, till exempel den faktiska VM-storleken (ServiceType) eller förhållandet där reservationsrabatten tillämpas.
|
|
properties.benefitId
|
string
|
Unik identifierare för den tillämpliga förmånen.
|
|
properties.benefitName
|
string
|
Namnet på den tillämpliga förmånen.
|
|
properties.billingAccountId
|
string
|
Identifierare för faktureringskonto.
|
|
properties.billingAccountName
|
string
|
Namnet på faktureringskontot.
|
|
properties.billingCurrencyCode
|
string
|
Valutan som definierar den fakturerade kostnaden.
|
|
properties.billingPeriodEndDate
|
string
(date-time)
|
Slutdatum för faktureringsperiod som i fakturan.
|
|
properties.billingPeriodStartDate
|
string
(date-time)
|
Startdatum för faktureringsperiod som i fakturan.
|
|
properties.billingProfileId
|
string
|
Identifierare för faktureringsprofilen som grupperar kostnader mellan fakturor i en enda faktureringsvaluta över de kunder som har registrerat Microsoft-kundavtalet och de kunder i CSP som har gjort berättigandeköp som SaaS, Marketplace, RI osv.
|
|
properties.billingProfileName
|
string
|
Namn på faktureringsprofilen som grupperar kostnader mellan fakturor i en enda faktureringsvaluta över de kunder som har registrerat Microsoft-kundavtalet och de kunder i CSP som har gjort berättigandeköp som SaaS, Marketplace, RI osv.
|
|
properties.chargeType
|
string
|
Anger att en avgift representerar krediter, användning, ett Marketplace-köp, en reservationsavgift eller en återbetalning.
|
|
properties.consumedService
|
string
|
Namn på förbrukad tjänst. Namnet på azure-resursprovidern som genererar användningen eller som har köpts. Det här värdet anges inte för marketplace-användning.
|
|
properties.costAllocationRuleName
|
string
|
Namn på kostnadsallokeringsregel.
|
|
properties.costCenter
|
string
|
Kostnadsställe för den här avdelningen om det är en avdelning och ett kostnadsställe tillhandahålls.
|
|
properties.costInBillingCurrency
|
number
(decimal)
|
ExtendedCost eller blandad kostnad före skatt i fakturerad valuta.
|
|
properties.costInPricingCurrency
|
number
(decimal)
|
ExtendedCost eller blandad kostnad före skatt i prisvaluta för att korrelera med priserna.
|
|
properties.costInUSD
|
number
(decimal)
|
Uppskattad extendedCost eller blandad kostnad före skatt i USD.
|
|
properties.customerName
|
string
|
Namnet på kundens AAD-klientorganisation.
|
|
properties.customerTenantId
|
string
|
Identifierare för kundens AAD-klientorganisation.
|
|
properties.date
|
string
(date-time)
|
Datum för användningsposten.
|
|
properties.effectivePrice
|
number
(decimal)
|
Effektivt pris som debiteras för användningen.
|
|
properties.exchangeRate
|
string
|
Växelkurs som används vid konvertering från prisvaluta till faktureringsvaluta.
|
|
properties.exchangeRateDate
|
string
(date-time)
|
Datum då växelkursen användes vid konvertering från prisvaluta till faktureringsvaluta.
|
|
properties.exchangeRatePricingToBilling
|
number
(decimal)
|
Växelkurs från prisvaluta till faktureringsvaluta.
|
|
properties.frequency
|
string
|
Anger hur ofta den här avgiften ska ske. OneTime för köp som bara sker en gång, Månadsvis för avgifter som återkommer varje månad och UsageBased för avgifter baserat på hur mycket en tjänst används.
|
|
properties.instanceName
|
string
|
Instansnamn.
|
|
properties.invoiceId
|
string
|
Faktura-ID som på fakturan där den specifika transaktionen visas.
|
|
properties.invoiceSectionId
|
string
|
Identifierare för projektet som debiteras på fakturan. Gäller inte för Microsoft-kundavtal som registrerats av partner.
|
|
properties.invoiceSectionName
|
string
|
Namnet på projektet som debiteras på fakturan. Gäller inte för Microsoft-kundavtal som registrerats av partner.
|
|
properties.isAzureCreditEligible
|
boolean
|
Avgör om kostnaden är berättigad att betalas för med hjälp av Azure-krediter.
|
|
properties.marketPrice
|
number
(decimal)
|
Marknadspris som debiteras för användningen.
|
|
properties.meterCategory
|
string
|
Identifierar tjänsten på den översta nivån för användningen.
|
|
properties.meterId
|
string
(uuid)
|
Mätar-ID (GUID). Inte tillgängligt för Marketplace. För reserverad instans representerar detta den primära mätaren som reservationen köptes för. För den faktiska VM-storlek som reservationen har köpts för, se productOrderName.
|
|
properties.meterName
|
string
|
Identifierar namnet på mätaren som förbrukningen mäts mot.
|
|
properties.meterRegion
|
string
|
Anger datacenterplats för vissa tjänster som prissätts beroende på var datacentret ligger.
|
|
properties.meterSubCategory
|
string
|
Definierar typen eller underkategorin för Azure-tjänsten som kan påverka priset.
|
|
properties.partnerEarnedCreditApplied
|
string
|
Flagga för att ange om partnerintjänad kredit har tillämpats eller inte.
|
|
properties.partnerEarnedCreditRate
|
number
(decimal)
|
Rabattsats tillämpas om det finns en partnerintjänad kredit (PEC) baserat på partneradministratörens länkåtkomst.
|
|
properties.partnerName
|
string
|
Namnet på partnerns AAD-klientorganisation.
|
|
properties.partnerTenantId
|
string
|
Identifierare för partnerns AAD-klientorganisation.
|
|
properties.payGPrice
|
number
(decimal)
|
Detaljhandelspris för resursen.
|
|
properties.paygCostInBillingCurrency
|
number
(decimal)
|
Beloppet för PayG-kostnaden före skatt i faktureringsvalutan.
|
|
properties.paygCostInUSD
|
number
(decimal)
|
Beloppet för PayG-kostnaden före skatt i us-dollarvaluta.
|
|
properties.previousInvoiceId
|
string
|
Referens till en ursprunglig faktura finns det en återbetalning (negativ kostnad). Detta fylls bara i när det finns en återbetalning.
|
|
properties.pricingCurrencyCode
|
string
|
Prisfaktureringsvaluta.
|
|
properties.pricingModel
|
PricingModelType
|
Identifierare som anger hur mätaren prissätts
|
|
properties.product
|
string
|
Namnet på den produkt som har upplupna avgifter efter förbrukning eller inköp enligt listan i fakturan. Inte tillgängligt för Marketplace.
|
|
properties.productIdentifier
|
string
|
Identifierare för den produkt som har upplupna avgifter efter förbrukning eller köp . Det här är den sammanfogade nyckeln för productId och SkuId i partnercenter.
|
|
properties.productOrderId
|
string
|
Identifieraren för den tillgång eller det Azure-plannamn som prenumerationen tillhör. Till exempel: Azure-plan. För reservationer är detta reservationsbeställnings-ID.
|
|
properties.productOrderName
|
string
|
Produktordernamn. För reservationer är detta den SKU som köptes.
|
|
properties.provider
|
string
|
Identifierare för produktkategori eller branschspecifik, t.ex. – Azure, Microsoft 365, AWS t.t.c
|
|
properties.publisherId
|
string
|
Utgivar-ID.
|
|
properties.publisherName
|
string
|
Namnet på utgivaren av tjänsten, inklusive Microsoft eller tredjepartsutgivare.
|
|
properties.publisherType
|
string
|
Typ av utgivare som identifierar om utgivaren är första part, tredjepartsåterförsäljare eller tredjepartsbyrå.
|
|
properties.quantity
|
number
(decimal)
|
Mät den kvantitet som köpts eller förbrukats. Mängden av mätaren som användes under faktureringsperioden.
|
|
properties.resellerMpnId
|
string
|
MPNId för den återförsäljare som är associerad med prenumerationen.
|
|
properties.resellerName
|
string
|
Återförsäljares namn.
|
|
properties.reservationId
|
string
|
ARM-resurs-ID för reservationen. Gäller endast poster som är relevanta för reservationer.
|
|
properties.reservationName
|
string
|
Användaren angav visningsnamnet för reservationen. Det senast kända namnet för en viss dag fylls i i de dagliga data. Gäller endast poster som är relevanta för reservationer.
|
|
properties.resourceGroup
|
string
|
Namnet på den Azure-resursgrupp som används för sammanhängande livscykelhantering av resurser.
|
|
properties.resourceLocation
|
string
|
Namnet på resursplatsen.
|
|
properties.resourceLocationNormalized
|
string
|
Resursplats normaliserad.
|
|
properties.serviceFamily
|
string
|
Visa en lista över tjänstfamiljen för den produkt som köpts eller debiterats (Exempel: Lagring ; Beräkning).
|
|
properties.serviceInfo1
|
string
|
Tjänstspecifika metadata.
|
|
properties.serviceInfo2
|
string
|
Äldre fält med valfria tjänstspecifika metadata.
|
|
properties.servicePeriodEndDate
|
string
(date-time)
|
Slutdatum för den period då tjänstanvändningen klassificerades för avgifter. Priserna för Azure-tjänster bestäms baserat på klassificeringsperioden.
|
|
properties.servicePeriodStartDate
|
string
(date-time)
|
Startdatum för klassificeringsperioden då tjänstanvändningen klassificerades för avgifter. Priserna för Azure-tjänster bestäms för klassificeringsperioden.
|
|
properties.subscriptionGuid
|
string
|
Unik Microsoft-genererad identifierare för Azure-prenumerationen.
|
|
properties.subscriptionName
|
string
|
Namnet på Azure-prenumerationen.
|
|
properties.term
|
string
|
Term (i månader). Visar termen för erbjudandets giltighet. Till exempel. Om reserverade instanser visas 12 månader för den reserverade instansens årliga period. För engångsköp eller återkommande köp visas villkoren 1 månad. Detta gäller inte för Azure-förbrukning.
|
|
properties.unitOfMeasure
|
string
|
Identifierar den enhet som tjänsten debiteras i. Till exempel GB, timmar, 10 000 s.
|
|
properties.unitPrice
|
number
(decimal)
|
Enhetspris är det pris som gäller för dig. (ditt EA eller annat kontraktspris).
|
|
systemData
|
systemData
|
Azure Resource Manager-metadata som innehåller createdBy och modifiedBy information.
|
|
tags
|
object
|
Resurstaggar.
|
|
type
|
string
|
Resurstypen. Till exempel "Microsoft.Compute/virtualMachines" eller "Microsoft.Storage/storageAccounts"
|
PricingModelType
Uppräkning
Identifierare som anger hur mätaren prissätts.
| Värde |
Description |
|
On Demand
|
|
|
Reservation
|
|
|
Spot
|
|
systemData
Objekt
Metadata som rör skapande och senaste ändring av resursen.
| Name |
Typ |
Description |
|
createdAt
|
string
(date-time)
|
Tidsstämpeln för resursskapande (UTC).
|
|
createdBy
|
string
|
Identiteten som skapade resursen.
|
|
createdByType
|
createdByType
|
Den typ av identitet som skapade resursen.
|
|
lastModifiedAt
|
string
(date-time)
|
Tidsstämpeln för resursens senaste ändring (UTC)
|
|
lastModifiedBy
|
string
|
Identiteten som senast ändrade resursen.
|
|
lastModifiedByType
|
createdByType
|
Den typ av identitet som senast ändrade resursen.
|
UsageDetailsKind
Uppräkning
Anger typen av användningsinformation.
| Värde |
Description |
|
legacy
|
|
|
modern
|
|
UsageDetailsListResult
Objekt
Resultat av att visa användningsinformation. Den innehåller en lista över tillgänglig användningsinformation i omvänd kronologisk ordning efter faktureringsperiod.
| Name |
Typ |
Description |
|
nextLink
|
string
|
Länken (url) till nästa resultatsida.
|
|
value
|
UsageDetail[]:
|
Listan över användningsinformation.
|