列出定义的范围的使用情况详细信息。 使用情况详细信息仅适用于 2014 年 5 月 1 日或更高版本的此 API。
注意:Microsoft将在将来的某个时间点停用消耗使用情况详细信息 API。 不建议对此 API 采用新的依赖项。 请改用成本详细信息 API。 确定停用日期后,我们会通知客户。有关详细信息,请参阅 生成成本详细信息报表 - 创建作
GET https://management.azure.com/{scope}/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
具有可选参数:
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 参数
| 名称 |
在 |
必需 |
类型 |
说明 |
|
scope
|
path |
True
|
string
|
资源的完全限定的 Azure 资源管理器标识符。
|
|
api-version
|
query |
True
|
string
minLength: 1
|
要用于此操作的 API 版本。
|
|
$expand
|
query |
|
string
|
可用于在使用情况详细信息列表中展开 properties/additionalInfo 或 properties/meterDetails。 默认情况下,列出使用情况详细信息时不包括这些字段。
|
|
$filter
|
query |
|
string
|
可用于按 properties/resourceGroup、properties/resourceName、properties/resourceId、properties/resourceId、properties/chargeType、properties/reservationId、properties/reservationId、properties/publisherType 或标记筛选 usageDetails。 该筛选器支持“eq”、“lt”、“gt”、“le”、“ge”和“and”。 它当前不支持“ne”、“or”或“not”。 标记筛选器是键值对字符串,其中键和值由冒号分隔(:))。 PublisherType Filter 接受 Azure 和市场两个值,目前支持 Web Direct 产品/服务类型
|
|
$skiptoken
|
query |
|
string
|
仅当以前的作返回了部分结果时,才使用 Skiptoken。 如果以前的响应包含 nextLink 元素,则 nextLink 元素的值将包含一个 skiptoken 参数,该参数指定用于后续调用的起点。
|
|
$top
|
query |
|
integer
(int32)
minimum: 1 maximum: 1000
|
可用于将结果数限制为最新的 N usageDetails。
|
|
metric
|
query |
|
Metrictype
|
允许选择不同类型的成本/使用情况记录。
|
响应
安全性
azure_auth
Azure Active Directory OAuth2 Flow。
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
| 名称 |
说明 |
|
user_impersonation
|
模拟用户帐户
|
示例
BillingAccountUsageDetailsList-Legacy
示例请求
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
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
示例响应
{
"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
示例请求
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234:56789/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
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
示例响应
{
"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
示例请求
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
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
示例响应
{
"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
示例请求
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/2468/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
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
示例响应
{
"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
示例请求
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
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
示例响应
{
"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
示例请求
GET https://management.azure.com/providers/Microsoft.Billing/Departments/1234/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
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
示例响应
{
"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
示例请求
GET https://management.azure.com/providers/Microsoft.Billing/Departments/1234/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
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
示例响应
{
"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
示例请求
GET https://management.azure.com/providers/Microsoft.Billing/EnrollmentAccounts/1234/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
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
示例响应
{
"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
示例请求
GET https://management.azure.com/providers/Microsoft.Billing/EnrollmentAccounts/1234/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
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
示例响应
{
"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
示例请求
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234:56789/invoiceSections/98765/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
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
示例响应
{
"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
示例请求
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
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
示例响应
{
"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
示例请求
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
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
示例响应
{
"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
示例请求
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
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
示例响应
{
"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
示例请求
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
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
示例响应
{
"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
示例请求
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01&metric=actualcost
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
示例响应
{
"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
示例请求
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01&metric=amortizedcost
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
示例响应
{
"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
示例请求
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01&metric=usage
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
示例响应
{
"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
示例请求
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'
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
示例响应
{
"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
示例请求
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails?api-version=2024-08-01
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
示例响应
{
"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"
}
}
]
}
定义
createdByType
枚举
创建资源的标识的类型。
| 值 |
说明 |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
ErrorAdditionalInfo
对象
资源管理错误附加信息。
| 名称 |
类型 |
说明 |
|
info
|
object
|
其他信息。
|
|
type
|
string
|
其他信息类型。
|
ErrorDetail
对象
错误详细信息。
ErrorResponse
对象
错误响应
LegacyUsageDetail
对象
旧版使用情况详细信息。
| 名称 |
类型 |
说明 |
|
etag
|
string
|
资源的 etag。
|
|
id
|
string
|
资源的完全限定资源 ID。 示例 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
kind
|
string:
legacy
|
指定使用情况详细信息的类型。
|
|
name
|
string
|
资源的名称
|
|
properties.accountName
|
string
|
帐户名称。
|
|
properties.accountOwnerId
|
string
|
帐户所有者 ID。
|
|
properties.additionalInfo
|
string
|
此使用项的其他详细信息。 默认情况下,除非在$expand中指定,否则不会填充它。 使用此字段可获取使用情况行项特定详细信息,例如实际 VM 大小(ServiceType)或应用预留折扣的比例。
|
|
properties.benefitId
|
string
|
适用权益的唯一标识符。
|
|
properties.benefitName
|
string
|
适用权益的名称。
|
|
properties.billingAccountId
|
string
|
计费帐户标识符。
|
|
properties.billingAccountName
|
string
|
计费帐户名称。
|
|
properties.billingCurrency
|
string
|
计费货币。
|
|
properties.billingPeriodEndDate
|
string
(date-time)
|
计费周期结束日期。
|
|
properties.billingPeriodStartDate
|
string
(date-time)
|
计费周期开始日期。
|
|
properties.billingProfileId
|
string
|
计费配置文件标识符。
|
|
properties.billingProfileName
|
string
|
计费配置文件名称。
|
|
properties.chargeType
|
string
|
指示费用表示额度、使用情况、市场购买、预留费或退款。
|
|
properties.consumedService
|
string
|
已使用的服务名称。 发出使用情况或购买的 Azure 资源提供程序的名称。 未为市场使用情况提供此值。
|
|
properties.cost
|
number
(decimal)
|
税前的成本金额。
|
|
properties.costCenter
|
string
|
如果此部门是部门和成本中心,则此部门的成本中心。
|
|
properties.date
|
string
(date-time)
|
使用情况记录的日期。
|
|
properties.effectivePrice
|
number
(decimal)
|
使用费的有效价格。
|
|
properties.frequency
|
string
|
指示此费用的发生频率。 OneTime 用于仅发生一次的购买、每月递归的费用,以及基于服务使用的费用的 UsageBased。
|
|
properties.invoiceSection
|
string
|
发票科目名称。
|
|
properties.isAzureCreditEligible
|
boolean
|
符合 Azure 额度条件。
|
|
properties.meterDetails
|
MeterDetailsResponse
|
有关计量的详细信息。 默认情况下,除非在$expand中指定,否则不会填充它。
|
|
properties.meterId
|
string
(uuid)
|
计量 ID (GUID)。 不适用于市场。 对于预留实例,这表示为其购买预留的主要计量。 有关购买预留的实际 VM 大小,请参阅 productOrderName。
|
|
properties.offerId
|
string
|
产品/服务 ID。例如:MS-AZR-0017P、MS-AZR-0148P。
|
|
properties.partNumber
|
string
|
使用的服务的部件号。 可用于与价目表联接。 不适用于市场。
|
|
properties.payGPrice
|
number
(decimal)
|
资源的零售价格。
|
|
properties.planName
|
string
|
计划名称。
|
|
properties.pricingModel
|
PricingModelType
|
指示计量器定价方式的标识符。
|
|
properties.product
|
string
|
已使用服务或购买的产品名称。 不适用于市场。
|
|
properties.productOrderId
|
string
|
产品订单 ID。对于预留,这是预留订单 ID。
|
|
properties.productOrderName
|
string
|
产品名称。 对于预留,这是购买的 SKU。
|
|
properties.publisherName
|
string
|
发布者名称。
|
|
properties.publisherType
|
string
|
发布服务器类型。
|
|
properties.quantity
|
number
(decimal)
|
使用数量。
|
|
properties.reservationId
|
string
|
预留的 ARM 资源 ID。 仅适用于与预留相关的记录。
|
|
properties.reservationName
|
string
|
用户提供的预留的显示名称。 特定日期的姓氏在每日数据中填充。 仅适用于与预留相关的记录。
|
|
properties.resourceGroup
|
string
|
资源组名称。
|
|
properties.resourceId
|
string
|
Azure 资源管理器使用情况详细信息资源的唯一标识符。
|
|
properties.resourceLocation
|
string
|
资源位置。
|
|
properties.resourceName
|
string
|
资源名称。
|
|
properties.serviceInfo1
|
string
|
服务特定的元数据。
|
|
properties.serviceInfo2
|
string
|
旧字段,具有可选的特定于服务的元数据。
|
|
properties.subscriptionId
|
string
|
订阅 guid。
|
|
properties.subscriptionName
|
string
|
订阅名称。
|
|
properties.term
|
string
|
术语(以月为单位)。 每月定期购买的 1 个月。 12 个月预订 1 年。 36 个月预订 3 年。
|
|
properties.unitPrice
|
number
(decimal)
|
单价是适用于你的价格。 (你的 EA 或其他合同价格)。
|
|
systemData
|
systemData
|
包含 createdBy 和 modifiedBy 信息的 Azure 资源管理器元数据。
|
|
tags
|
object
|
资源标记。
|
|
type
|
string
|
资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
MeterDetailsResponse
对象
计量详细信息的属性。
| 名称 |
类型 |
说明 |
|
meterCategory
|
string
|
计量的类别,例如“云服务”、“网络”等。
|
|
meterName
|
string
|
给定计量类别中的计量名称
|
|
meterSubCategory
|
string
|
计量的子类别,例如“A6 云服务”、“ExpressRoute (IXP)”等。
|
|
serviceFamily
|
string
|
服务系列。
|
|
unitOfMeasure
|
string
|
计量消耗费用的单位,例如“小时”、“GB”等。
|
Metrictype
枚举
| 值 |
说明 |
|
actualcost
|
实际成本数据。
|
|
amortizedcost
|
摊销成本数据。
|
|
usage
|
使用情况数据。
|
ModernUsageDetail
对象
新式用法详细信息。
| 名称 |
类型 |
说明 |
|
etag
|
string
|
资源的 etag。
|
|
id
|
string
|
资源的完全限定资源 ID。 示例 - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
kind
|
string:
modern
|
指定使用情况详细信息的类型。
|
|
name
|
string
|
资源的名称
|
|
properties.additionalInfo
|
string
|
此使用项的其他详细信息。 使用此字段可获取使用情况行项特定详细信息,例如实际 VM 大小(ServiceType)或应用预留折扣的比例。
|
|
properties.benefitId
|
string
|
适用权益的唯一标识符。
|
|
properties.benefitName
|
string
|
适用权益的名称。
|
|
properties.billingAccountId
|
string
|
计费帐户标识符。
|
|
properties.billingAccountName
|
string
|
计费帐户的名称。
|
|
properties.billingCurrencyCode
|
string
|
定义计费成本的货币。
|
|
properties.billingPeriodEndDate
|
string
(date-time)
|
发票中所示的计费周期结束日期。
|
|
properties.billingPeriodStartDate
|
string
(date-time)
|
发票中的计费周期开始日期。
|
|
properties.billingProfileId
|
string
|
计费配置文件的标识符,该配置文件按单一计费货币对已加入Microsoft客户协议的客户和 CSP 中已进行权利购买的客户(如 SaaS、市场、RI 等)的成本进行分组。
|
|
properties.billingProfileName
|
string
|
按单一计费货币将发票的成本分组到已加入Microsoft客户协议的客户和 CSP 中已进行权利购买的客户(如 SaaS、市场、RI 等)的计费配置文件的名称。
|
|
properties.chargeType
|
string
|
指示费用表示额度、使用情况、市场购买、预留费或退款。
|
|
properties.consumedService
|
string
|
已使用的服务名称。 发出使用情况或购买的 Azure 资源提供程序的名称。 未为市场使用情况提供此值。
|
|
properties.costAllocationRuleName
|
string
|
成本分配规则的名称。
|
|
properties.costCenter
|
string
|
如果此部门是部门和成本中心,则此部门的成本中心。
|
|
properties.costInBillingCurrency
|
number
(decimal)
|
在按计费货币征税之前,ExtendedCost 或混合成本。
|
|
properties.costInPricingCurrency
|
number
(decimal)
|
与价格关联的采用定价货币的 ExtendedCost 或混合税前成本。
|
|
properties.costInUSD
|
number
(decimal)
|
估计的延长成本或混合成本之前,税前为美元。
|
|
properties.customerName
|
string
|
客户的 AAD 租户的名称。
|
|
properties.customerTenantId
|
string
|
客户的 AAD 租户的标识符。
|
|
properties.date
|
string
(date-time)
|
使用情况记录的日期。
|
|
properties.effectivePrice
|
number
(decimal)
|
使用费的有效价格。
|
|
properties.exchangeRate
|
string
|
从定价货币转换为计费货币的汇率。
|
|
properties.exchangeRateDate
|
string
(date-time)
|
从定价货币转换为计费货币的汇率的日期。
|
|
properties.exchangeRatePricingToBilling
|
number
(decimal)
|
从定价货币到计费货币的汇率。
|
|
properties.frequency
|
string
|
指示此费用的发生频率。 OneTime 用于仅发生一次的购买、每月递归的费用,以及基于服务使用的费用的 UsageBased。
|
|
properties.instanceName
|
string
|
实例名称。
|
|
properties.invoiceId
|
string
|
发票 ID,如显示特定交易的发票上所示。
|
|
properties.invoiceSectionId
|
string
|
在发票中计费的项目的标识符。 不适用于合作伙伴加入的 Microsoft 客户协议。
|
|
properties.invoiceSectionName
|
string
|
在发票中计费的项目的名称。 不适用于合作伙伴加入的 Microsoft 客户协议。
|
|
properties.isAzureCreditEligible
|
boolean
|
确定成本是否符合使用 Azure 额度付费的条件。
|
|
properties.marketPrice
|
number
(decimal)
|
按使用量收费的市场价格。
|
|
properties.meterCategory
|
string
|
标识使用情况的顶级服务。
|
|
properties.meterId
|
string
(uuid)
|
计量 ID (GUID)。 不适用于市场。 对于预留实例,这表示为其购买预留的主要计量。 有关购买预留的实际 VM 大小,请参阅 productOrderName。
|
|
properties.meterName
|
string
|
标识度量消耗量所针对的计量的名称。
|
|
properties.meterRegion
|
string
|
指明某些服务的数据中心的位置,这些服务根据数据中心位置进行定价。
|
|
properties.meterSubCategory
|
string
|
定义可能影响速率的 Azure 服务的类型或子类别。
|
|
properties.partnerEarnedCreditApplied
|
string
|
指示是否已应用合作伙伴赚取的返点的标志。
|
|
properties.partnerEarnedCreditRate
|
number
(decimal)
|
如果合作伙伴赚取的额度(PEC)基于合作伙伴管理员链接访问权限,则应用的折扣率。
|
|
properties.partnerName
|
string
|
合作伙伴的 AAD 租户的名称。
|
|
properties.partnerTenantId
|
string
|
合作伙伴 AAD 租户的标识符。
|
|
properties.payGPrice
|
number
(decimal)
|
资源的零售价格。
|
|
properties.paygCostInBillingCurrency
|
number
(decimal)
|
以计费货币计税前的 PayG 成本金额。
|
|
properties.paygCostInUSD
|
number
(decimal)
|
以美元货币计税前的 PayG 成本金额。
|
|
properties.previousInvoiceId
|
string
|
对原始发票的引用存在退款(负成本)。 仅当存在退款时,才会填充此项。
|
|
properties.pricingCurrencyCode
|
string
|
定价计费货币。
|
|
properties.pricingModel
|
PricingModelType
|
指示计量定价方式的标识符
|
|
properties.product
|
string
|
按发票中列出的消费或购买产生费用的产品的名称。 不适用于市场。
|
|
properties.productIdentifier
|
string
|
按消耗或购买产生费用的产品的标识符。 这是合作伙伴中心 productId 和 SkuId 的串联密钥。
|
|
properties.productOrderId
|
string
|
订阅所属的资产或 Azure 计划名称的标识符。 例如:Azure 计划。 对于预留,这是预留订单 ID。
|
|
properties.productOrderName
|
string
|
产品名称。 对于预留,这是购买的 SKU。
|
|
properties.provider
|
string
|
产品类别或业务线的标识符,例如 - Azure,Microsoft 365,AWS e.t.c
|
|
properties.publisherId
|
string
|
发布者 ID。
|
|
properties.publisherName
|
string
|
服务发布者的名称,包括Microsoft或第三方发布者。
|
|
properties.publisherType
|
string
|
标识发布者是否是第一方、第三方经销商或第三方代理的发布者类型。
|
|
properties.quantity
|
number
(decimal)
|
测量购买或消耗的数量。计费期间使用的计量量。
|
|
properties.resellerMpnId
|
string
|
与订阅关联的经销商的 MPNId。
|
|
properties.resellerName
|
string
|
经销商名称。
|
|
properties.reservationId
|
string
|
预留的 ARM 资源 ID。 仅适用于与预留相关的记录。
|
|
properties.reservationName
|
string
|
用户提供的预留的显示名称。 特定日期的姓氏在每日数据中填充。 仅适用于与预留相关的记录。
|
|
properties.resourceGroup
|
string
|
用于资源统一生命周期管理的 Azure 资源组的名称。
|
|
properties.resourceLocation
|
string
|
资源位置的名称。
|
|
properties.resourceLocationNormalized
|
string
|
资源位置规范化。
|
|
properties.serviceFamily
|
string
|
列出购买或收费的产品的服务系列(示例:存储;计算)。
|
|
properties.serviceInfo1
|
string
|
服务特定的元数据。
|
|
properties.serviceInfo2
|
string
|
旧字段,具有可选的特定于服务的元数据。
|
|
properties.servicePeriodEndDate
|
string
(date-time)
|
为服务用量分级费用时的时段结束日期。 将根据分级时段确定 Azure 服务的价格。
|
|
properties.servicePeriodStartDate
|
string
(date-time)
|
为服务用量分级费用时分级时段的开始日期。 将根据分级时段确定 Azure 服务的价格。
|
|
properties.subscriptionGuid
|
string
|
Azure 订阅的唯一Microsoft生成的标识符。
|
|
properties.subscriptionName
|
string
|
Azure 订阅的名称。
|
|
properties.term
|
string
|
术语(以月为单位)。 显示套餐的有效期限。 例如。 对于预留实例,它显示预留实例的每年期限为 12 个月。 对于一次性购买或定期购买,条款显示 1 个月;这不适用于 Azure 消耗。
|
|
properties.unitOfMeasure
|
string
|
标识服务按其计费的单位。 例如,GB、小时、10,000 秒。
|
|
properties.unitPrice
|
number
(decimal)
|
单价是适用于你的价格。 (你的 EA 或其他合同价格)。
|
|
systemData
|
systemData
|
包含 createdBy 和 modifiedBy 信息的 Azure 资源管理器元数据。
|
|
tags
|
object
|
资源标记。
|
|
type
|
string
|
资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
PricingModelType
枚举
指示计量器定价方式的标识符。
| 值 |
说明 |
|
On Demand
|
|
|
Reservation
|
|
|
Spot
|
|
systemData
对象
与创建和上次修改资源相关的元数据。
| 名称 |
类型 |
说明 |
|
createdAt
|
string
(date-time)
|
资源创建时间戳(UTC)。
|
|
createdBy
|
string
|
创建资源的标识。
|
|
createdByType
|
createdByType
|
创建资源的标识的类型。
|
|
lastModifiedAt
|
string
(date-time)
|
上次修改的资源时间戳(UTC)
|
|
lastModifiedBy
|
string
|
上次修改资源的标识。
|
|
lastModifiedByType
|
createdByType
|
上次修改资源的标识的类型。
|
UsageDetailsKind
枚举
指定使用情况详细信息的类型。
UsageDetailsListResult
对象
列出使用情况详细信息的结果。 它包含按计费周期按时间顺序排列的可用使用情况详细信息列表。
| 名称 |
类型 |
说明 |
|
nextLink
|
string
|
指向下一页结果的链接(url)。
|
|
value
|
UsageDetail[]:
|
使用情况详细信息的列表。
|