Lists the charges based for the defined scope.
GET https://management.azure.com/{scope}/providers/Microsoft.Consumption/charges?api-version=2024-08-01
With optional parameters:
GET https://management.azure.com/{scope}/providers/Microsoft.Consumption/charges?api-version=2024-08-01&startDate={startDate}&endDate={endDate}&$filter={$filter}&$apply={$apply}
URI Parameters
| Name |
In |
Required |
Type |
Description |
|
scope
|
path |
True
|
string
|
The fully qualified Azure Resource manager identifier of the resource.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
The API version to use for this operation.
|
|
$apply
|
query |
|
string
|
May be used to group charges for billingAccount scope by properties/billingProfileId, properties/invoiceSectionId, properties/customerId (specific for Partner Led), or for billingProfile scope by properties/invoiceSectionId.
|
|
$filter
|
query |
|
string
|
May be used to filter charges by properties/usageEnd (Utc time), properties/usageStart (Utc time). The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and value is separated by a colon (:).
|
|
endDate
|
query |
|
string
|
End date
|
|
startDate
|
query |
|
string
|
Start date
|
Responses
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
| Name |
Description |
|
user_impersonation
|
impersonate your user account
|
Examples
ChangesForBillingPeriodByDepartment-Legacy
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234/departments/42425/providers/Microsoft.Consumption/charges?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python charges_for_billing_period_by_department.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.charges.list(
scope="providers/Microsoft.Billing/BillingAccounts/1234/departments/42425",
)
print(response)
# x-ms-original-file: 2024-08-01/ChargesForBillingPeriodByDepartment.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ChargesForBillingPeriodByDepartment.json
func ExampleChargesClient_List_changesForBillingPeriodByDepartmentLegacy() {
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)
}
res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/BillingAccounts/1234/departments/42425", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armconsumption.ChargesClientListResponse{
// ChargesListResult: &armconsumption.ChargesListResult{
// Value: []armconsumption.ChargeSummaryClassification{
// &armconsumption.LegacyChargeSummary{
// Name: to.Ptr("chargeSummaryId1"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/departments/42425/providers/Microsoft.Consumption/charges/chargeSummaryId1"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindLegacy),
// Properties: &armconsumption.LegacyChargeSummaryProperties{
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201804"),
// Currency: to.Ptr("USD"),
// UsageEnd: to.Ptr("2018-04-30"),
// UsageStart: to.Ptr("2018-04-01"),
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "chargeSummaryId1",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/BillingAccounts/1234/departments/42425/providers/Microsoft.Consumption/charges/chargeSummaryId1",
"kind": "legacy",
"properties": {
"azureCharges": 5000,
"azureMarketplaceCharges": 100,
"billingPeriodId": "/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201804",
"chargesBilledSeparately": 60.9,
"currency": "USD",
"usageEnd": "2018-04-30",
"usageStart": "2018-04-01"
}
}
]
}
ChangesForBillingPeriodByEnrollmentAccount-Legacy
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234/enrollmentAccounts/42425/providers/Microsoft.Consumption/charges?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python charges_for_billing_period_by_enrollment_account.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.charges.list(
scope="providers/Microsoft.Billing/BillingAccounts/1234/enrollmentAccounts/42425",
)
print(response)
# x-ms-original-file: 2024-08-01/ChargesForBillingPeriodByEnrollmentAccount.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ChargesForBillingPeriodByEnrollmentAccount.json
func ExampleChargesClient_List_changesForBillingPeriodByEnrollmentAccountLegacy() {
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)
}
res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/BillingAccounts/1234/enrollmentAccounts/42425", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armconsumption.ChargesClientListResponse{
// ChargesListResult: &armconsumption.ChargesListResult{
// Value: []armconsumption.ChargeSummaryClassification{
// &armconsumption.LegacyChargeSummary{
// Name: to.Ptr("chargeSummaryId1"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/enrollmentAccounts/42425/providers/Microsoft.Consumption/charges/chargeSummaryId1"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindLegacy),
// Properties: &armconsumption.LegacyChargeSummaryProperties{
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201804"),
// Currency: to.Ptr("USD"),
// UsageEnd: to.Ptr("2018-04-30"),
// UsageStart: to.Ptr("2018-04-01"),
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "chargeSummaryId1",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/BillingAccounts/1234/enrollmentAccounts/42425/providers/Microsoft.Consumption/charges/chargeSummaryId1",
"kind": "legacy",
"properties": {
"azureCharges": 5000,
"azureMarketplaceCharges": 100,
"billingPeriodId": "/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201804",
"chargesBilledSeparately": 60.9,
"currency": "USD",
"usageEnd": "2018-04-30",
"usageStart": "2018-04-01"
}
}
]
}
ChargesListByBillingAccount-Modern
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Consumption/charges?api-version=2024-08-01&startDate=2019-09-01&endDate=2019-10-31
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python charges_list_by_modern_billing_account.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.charges.list(
scope="providers/Microsoft.Billing/billingAccounts/1234:56789",
)
print(response)
# x-ms-original-file: 2024-08-01/ChargesListByModernBillingAccount.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ChargesListByModernBillingAccount.json
func ExampleChargesClient_List_chargesListByBillingAccountModern() {
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)
}
res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/1234:56789", &armconsumption.ChargesClientListOptions{
EndDate: to.Ptr("2019-10-31"),
StartDate: to.Ptr("2019-09-01")})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armconsumption.ChargesClientListResponse{
// ChargesListResult: &armconsumption.ChargesListResult{
// Value: []armconsumption.ChargeSummaryClassification{
// &armconsumption.ModernChargeSummary{
// Name: to.Ptr("chargeSummaryId1"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Consumption/charges/chargeSummaryId1"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindModern),
// Properties: &armconsumption.ModernChargeSummaryProperties{
// AzureCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"),
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910"),
// ChargesBilledSeparately: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// IsInvoiced: to.Ptr(false),
// MarketplaceCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// UsageEnd: to.Ptr("2019-10-31"),
// UsageStart: to.Ptr("2019-09-01"),
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "chargeSummaryId1",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Consumption/charges/chargeSummaryId1",
"kind": "modern",
"properties": {
"azureCharges": {
"currency": "USD",
"value": 0
},
"billingAccountId": "/providers/Microsoft.Billing/billingAccounts/1234:56789",
"billingPeriodId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910",
"billingProfileId": null,
"chargesBilledSeparately": {
"currency": "USD",
"value": 265.09
},
"invoiceSectionId": null,
"isInvoiced": false,
"marketplaceCharges": {
"currency": "USD",
"value": 0
},
"usageEnd": "2019-10-31",
"usageStart": "2019-09-01"
}
}
]
}
ChargesListByBillingAccountGroupByBillingProfileId-Modern
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Consumption/charges?api-version=2024-08-01&startDate=2019-09-01&endDate=2019-09-30&$apply=groupby((properties/billingProfileId))
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python charges_list_by_modern_billing_account_group_by_billing_profile_id.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.charges.list(
scope="providers/Microsoft.Billing/billingAccounts/1234:56789",
)
print(response)
# x-ms-original-file: 2024-08-01/ChargesListByModernBillingAccountGroupByBillingProfileId.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ChargesListByModernBillingAccountGroupByBillingProfileId.json
func ExampleChargesClient_List_chargesListByBillingAccountGroupByBillingProfileIdModern() {
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)
}
res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/1234:56789", &armconsumption.ChargesClientListOptions{
Apply: to.Ptr("groupby((properties/billingProfileId))"),
EndDate: to.Ptr("2019-09-30"),
StartDate: to.Ptr("2019-09-01")})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armconsumption.ChargesClientListResponse{
// ChargesListResult: &armconsumption.ChargesListResult{
// Value: []armconsumption.ChargeSummaryClassification{
// &armconsumption.ModernChargeSummary{
// Name: to.Ptr("chargeSummaryId1"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Consumption/charges/chargeSummaryId1"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindModern),
// Properties: &armconsumption.ModernChargeSummaryProperties{
// AzureCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"),
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/123456/providers/Microsoft.Billing/billingPeriods/201909"),
// BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/123456"),
// ChargesBilledSeparately: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// IsInvoiced: to.Ptr(false),
// MarketplaceCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// UsageEnd: to.Ptr("2019-09-30"),
// UsageStart: to.Ptr("2019-09-01"),
// },
// },
// &armconsumption.ModernChargeSummary{
// Name: to.Ptr("chargeSummaryId2"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/42425/providers/Microsoft.Consumption/charges/chargeSummaryId2"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindModern),
// Properties: &armconsumption.ModernChargeSummaryProperties{
// AzureCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"),
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"),
// BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"),
// ChargesBilledSeparately: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// MarketplaceCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// UsageEnd: to.Ptr("2019-09-30"),
// UsageStart: to.Ptr("2019-09-01"),
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "chargeSummaryId1",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Consumption/charges/chargeSummaryId1",
"kind": "modern",
"properties": {
"azureCharges": {
"currency": "USD",
"value": 5000
},
"billingAccountId": "/providers/Microsoft.Billing/billingAccounts/1234:56789",
"billingPeriodId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/123456/providers/Microsoft.Billing/billingPeriods/201909",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/123456",
"chargesBilledSeparately": {
"currency": "USD",
"value": 60.9
},
"isInvoiced": false,
"marketplaceCharges": {
"currency": "USD",
"value": 100
},
"usageEnd": "2019-09-30",
"usageStart": "2019-09-01"
}
},
{
"name": "chargeSummaryId2",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/42425/providers/Microsoft.Consumption/charges/chargeSummaryId2",
"kind": "modern",
"properties": {
"azureCharges": {
"currency": "USD",
"value": 5000
},
"billingAccountId": "/providers/Microsoft.Billing/billingAccounts/1234:56789",
"billingPeriodId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425",
"chargesBilledSeparately": {
"currency": "USD",
"value": 60.9
},
"marketplaceCharges": {
"currency": "USD",
"value": 100
},
"usageEnd": "2019-09-30",
"usageStart": "2019-09-01"
}
}
]
}
ChargesListByBillingAccountGroupByCustomerId-Modern
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Consumption/charges?api-version=2024-08-01&startDate=2019-09-01&endDate=2019-09-30&$apply=groupby((properties/customerId))
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python charges_list_by_modern_billing_account_group_by_customer_id.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.charges.list(
scope="providers/Microsoft.Billing/billingAccounts/1234:56789",
)
print(response)
# x-ms-original-file: 2024-08-01/ChargesListByModernBillingAccountGroupByCustomerId.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ChargesListByModernBillingAccountGroupByCustomerId.json
func ExampleChargesClient_List_chargesListByBillingAccountGroupByCustomerIdModern() {
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)
}
res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/1234:56789", &armconsumption.ChargesClientListOptions{
Apply: to.Ptr("groupby((properties/customerId))"),
EndDate: to.Ptr("2019-09-30"),
StartDate: to.Ptr("2019-09-01")})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armconsumption.ChargesClientListResponse{
// ChargesListResult: &armconsumption.ChargesListResult{
// Value: []armconsumption.ChargeSummaryClassification{
// &armconsumption.ModernChargeSummary{
// Name: to.Ptr("chargeSummaryId1"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/customers/67890/providers/Microsoft.Consumption/charges/chargeSummaryId1"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindModern),
// Properties: &armconsumption.ModernChargeSummaryProperties{
// AzureCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"),
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"),
// BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"),
// ChargesBilledSeparately: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/customers/67890"),
// InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/67890"),
// IsInvoiced: to.Ptr(false),
// MarketplaceCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// UsageEnd: to.Ptr("2019-09-30"),
// UsageStart: to.Ptr("2019-09-01"),
// },
// },
// &armconsumption.ModernChargeSummary{
// Name: to.Ptr("chargeSummaryId2"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789/customers/123456/providers/Microsoft.Consumption/charges/chargeSummaryId2"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindModern),
// Properties: &armconsumption.ModernChargeSummaryProperties{
// AzureCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"),
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"),
// BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"),
// ChargesBilledSeparately: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/customers/123456"),
// InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/67890"),
// IsInvoiced: to.Ptr(false),
// MarketplaceCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// UsageEnd: to.Ptr("2019-09-30"),
// UsageStart: to.Ptr("2019-09-01"),
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "chargeSummaryId1",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/billingAccounts/1234:56789/customers/67890/providers/Microsoft.Consumption/charges/chargeSummaryId1",
"kind": "modern",
"properties": {
"azureCharges": {
"currency": "USD",
"value": 5000
},
"billingAccountId": "/providers/Microsoft.Billing/billingAccounts/1234:56789",
"billingPeriodId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425",
"chargesBilledSeparately": {
"currency": "USD",
"value": 60.9
},
"customerId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/customers/67890",
"invoiceSectionId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/67890",
"isInvoiced": false,
"marketplaceCharges": {
"currency": "USD",
"value": 100
},
"usageEnd": "2019-09-30",
"usageStart": "2019-09-01"
}
},
{
"name": "chargeSummaryId2",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/BillingAccounts/1234:56789/customers/123456/providers/Microsoft.Consumption/charges/chargeSummaryId2",
"kind": "modern",
"properties": {
"azureCharges": {
"currency": "USD",
"value": 5000
},
"billingAccountId": "/providers/Microsoft.Billing/billingAccounts/1234:56789",
"billingPeriodId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425",
"chargesBilledSeparately": {
"currency": "USD",
"value": 60.9
},
"customerId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/customers/123456",
"invoiceSectionId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/67890",
"isInvoiced": false,
"marketplaceCharges": {
"currency": "USD",
"value": 100
},
"usageEnd": "2019-09-30",
"usageStart": "2019-09-01"
}
}
]
}
ChargesListByBillingAccountGroupByInvoiceSectionId-Modern
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/providers/Microsoft.Consumption/charges?api-version=2024-08-01&startDate=2019-09-01&endDate=2019-09-30&$apply=groupby((properties/invoiceSectionId))
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python charges_list_by_modern_billing_account_group_by_invoice_section_id.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.charges.list(
scope="providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425",
)
print(response)
# x-ms-original-file: 2024-08-01/ChargesListByModernBillingAccountGroupByInvoiceSectionId.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ChargesListByModernBillingAccountGroupByInvoiceSectionId.json
func ExampleChargesClient_List_chargesListByBillingAccountGroupByInvoiceSectionIdModern() {
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)
}
res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425", &armconsumption.ChargesClientListOptions{
Apply: to.Ptr("groupby((properties/invoiceSectionId))"),
EndDate: to.Ptr("2019-09-30"),
StartDate: to.Ptr("2019-09-01")})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armconsumption.ChargesClientListResponse{
// ChargesListResult: &armconsumption.ChargesListResult{
// Value: []armconsumption.ChargeSummaryClassification{
// &armconsumption.ModernChargeSummary{
// Name: to.Ptr("chargeSummaryId1"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/4567/providers/Microsoft.Consumption/charges/chargeSummaryId1"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindModern),
// Properties: &armconsumption.ModernChargeSummaryProperties{
// AzureCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"),
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"),
// BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"),
// ChargesBilledSeparately: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/4567"),
// IsInvoiced: to.Ptr(false),
// MarketplaceCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// UsageEnd: to.Ptr("2019-09-30"),
// UsageStart: to.Ptr("2019-09-01"),
// },
// },
// &armconsumption.ModernChargeSummary{
// Name: to.Ptr("chargeSummaryId2"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789//billingProfiles/42425/invoiceSections/67890/providers/Microsoft.Consumption/charges/chargeSummaryId2"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindModern),
// Properties: &armconsumption.ModernChargeSummaryProperties{
// AzureCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"),
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"),
// BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"),
// ChargesBilledSeparately: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/67890"),
// IsInvoiced: to.Ptr(false),
// MarketplaceCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// UsageEnd: to.Ptr("2019-09-30"),
// UsageStart: to.Ptr("2019-09-01"),
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "chargeSummaryId1",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/4567/providers/Microsoft.Consumption/charges/chargeSummaryId1",
"kind": "modern",
"properties": {
"azureCharges": {
"currency": "USD",
"value": 5000
},
"billingAccountId": "/providers/Microsoft.Billing/billingAccounts/1234:56789",
"billingPeriodId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425",
"chargesBilledSeparately": {
"currency": "USD",
"value": 60.9
},
"invoiceSectionId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/4567",
"isInvoiced": false,
"marketplaceCharges": {
"currency": "USD",
"value": 100
},
"usageEnd": "2019-09-30",
"usageStart": "2019-09-01"
}
},
{
"name": "chargeSummaryId2",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/BillingAccounts/1234:56789//billingProfiles/42425/invoiceSections/67890/providers/Microsoft.Consumption/charges/chargeSummaryId2",
"kind": "modern",
"properties": {
"azureCharges": {
"currency": "USD",
"value": 5000
},
"billingAccountId": "/providers/Microsoft.Billing/billingAccounts/1234:56789",
"billingPeriodId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425",
"chargesBilledSeparately": {
"currency": "USD",
"value": 60.9
},
"invoiceSectionId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/67890",
"isInvoiced": false,
"marketplaceCharges": {
"currency": "USD",
"value": 100
},
"usageEnd": "2019-09-30",
"usageStart": "2019-09-01"
}
}
]
}
ChargesListByBillingProfile-Modern
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/2460/providers/Microsoft.Consumption/charges?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python charges_list_by_modern_billing_profile.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.charges.list(
scope="providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/2460",
)
print(response)
# x-ms-original-file: 2024-08-01/ChargesListByModernBillingProfile.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ChargesListByModernBillingProfile.json
func ExampleChargesClient_List_chargesListByBillingProfileModern() {
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)
}
res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/2460", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armconsumption.ChargesClientListResponse{
// ChargesListResult: &armconsumption.ChargesListResult{
// Value: []armconsumption.ChargeSummaryClassification{
// &armconsumption.ModernChargeSummary{
// Name: to.Ptr("chargeSummaryId1"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460/providers/Microsoft.Consumption/charges/chargeSummaryId1"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindModern),
// Properties: &armconsumption.ModernChargeSummaryProperties{
// AzureCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"),
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910"),
// BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460"),
// ChargesBilledSeparately: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// IsInvoiced: to.Ptr(false),
// MarketplaceCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// UsageEnd: to.Ptr("2023-05-31"),
// UsageStart: to.Ptr("2023-03-01"),
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "chargeSummaryId1",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460/providers/Microsoft.Consumption/charges/chargeSummaryId1",
"kind": "modern",
"properties": {
"azureCharges": {
"currency": "USD",
"value": 0
},
"billingAccountId": "/providers/Microsoft.Billing/billingAccounts/1234:56789",
"billingPeriodId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460",
"chargesBilledSeparately": {
"currency": "USD",
"value": 265.09
},
"invoiceSectionId": null,
"isInvoiced": false,
"marketplaceCharges": {
"currency": "USD",
"value": 0
},
"usageEnd": "2023-05-31",
"usageStart": "2023-03-01"
}
}
]
}
ChargesListByBillingProfileGroupByInvoiceSectionId-Modern
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/providers/Microsoft.Consumption/charges?api-version=2024-08-01&startDate=2019-09-01&endDate=2019-09-30&$apply=groupby((properties/invoiceSectionId))
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python charges_list_by_modern_billing_profile_group_by_invoice_section_id.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.charges.list(
scope="providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425",
)
print(response)
# x-ms-original-file: 2024-08-01/ChargesListByModernBillingProfileGroupByInvoiceSectionId.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ChargesListByModernBillingProfileGroupByInvoiceSectionId.json
func ExampleChargesClient_List_chargesListByBillingProfileGroupByInvoiceSectionIdModern() {
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)
}
res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425", &armconsumption.ChargesClientListOptions{
Apply: to.Ptr("groupby((properties/invoiceSectionId))"),
EndDate: to.Ptr("2019-09-30"),
StartDate: to.Ptr("2019-09-01")})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armconsumption.ChargesClientListResponse{
// ChargesListResult: &armconsumption.ChargesListResult{
// Value: []armconsumption.ChargeSummaryClassification{
// &armconsumption.ModernChargeSummary{
// Name: to.Ptr("chargeSummaryId1"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/4567/providers/Microsoft.Consumption/charges/chargeSummaryId1"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindModern),
// Properties: &armconsumption.ModernChargeSummaryProperties{
// AzureCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"),
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"),
// BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"),
// ChargesBilledSeparately: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/4567"),
// IsInvoiced: to.Ptr(false),
// MarketplaceCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// UsageEnd: to.Ptr("2019-09-30"),
// UsageStart: to.Ptr("2019-09-01"),
// },
// },
// &armconsumption.ModernChargeSummary{
// Name: to.Ptr("chargeSummaryId2"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789//billingProfiles/42425/invoiceSections/67890/providers/Microsoft.Consumption/charges/chargeSummaryId2"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindModern),
// Properties: &armconsumption.ModernChargeSummaryProperties{
// AzureCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"),
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"),
// BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"),
// ChargesBilledSeparately: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/67890"),
// IsInvoiced: to.Ptr(false),
// MarketplaceCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// UsageEnd: to.Ptr("2019-09-30"),
// UsageStart: to.Ptr("2019-09-01"),
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "chargeSummaryId1",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/4567/providers/Microsoft.Consumption/charges/chargeSummaryId1",
"kind": "modern",
"properties": {
"azureCharges": {
"currency": "USD",
"value": 5000
},
"billingAccountId": "/providers/Microsoft.Billing/billingAccounts/1234:56789",
"billingPeriodId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425",
"chargesBilledSeparately": {
"currency": "USD",
"value": 60.9
},
"invoiceSectionId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/4567",
"isInvoiced": false,
"marketplaceCharges": {
"currency": "USD",
"value": 100
},
"usageEnd": "2019-09-30",
"usageStart": "2019-09-01"
}
},
{
"name": "chargeSummaryId2",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/BillingAccounts/1234:56789//billingProfiles/42425/invoiceSections/67890/providers/Microsoft.Consumption/charges/chargeSummaryId2",
"kind": "modern",
"properties": {
"azureCharges": {
"currency": "USD",
"value": 5000
},
"billingAccountId": "/providers/Microsoft.Billing/billingAccounts/1234:56789",
"billingPeriodId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425",
"chargesBilledSeparately": {
"currency": "USD",
"value": 60.9
},
"invoiceSectionId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/67890",
"isInvoiced": false,
"marketplaceCharges": {
"currency": "USD",
"value": 100
},
"usageEnd": "2019-09-30",
"usageStart": "2019-09-01"
}
}
]
}
ChargesListByBillingProfileInvoiceSection-Modern
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/67890/providers/Microsoft.Consumption/charges?api-version=2024-08-01&startDate=2019-09-01&endDate=2019-10-31
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python charges_list_by_modern_billing_profile_invoice_section.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.charges.list(
scope="providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/67890",
)
print(response)
# x-ms-original-file: 2024-08-01/ChargesListByModernBillingProfileInvoiceSection.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ChargesListByModernBillingProfileInvoiceSection.json
func ExampleChargesClient_List_chargesListByBillingProfileInvoiceSectionModern() {
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)
}
res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/67890", &armconsumption.ChargesClientListOptions{
EndDate: to.Ptr("2019-10-31"),
StartDate: to.Ptr("2019-09-01")})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armconsumption.ChargesClientListResponse{
// ChargesListResult: &armconsumption.ChargesListResult{
// Value: []armconsumption.ChargeSummaryClassification{
// &armconsumption.ModernChargeSummary{
// Name: to.Ptr("chargeSummaryId1"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/67890/providers/Microsoft.Consumption/charges/chargeSummaryId1"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindModern),
// Properties: &armconsumption.ModernChargeSummaryProperties{
// AzureCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"),
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"),
// BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"),
// ChargesBilledSeparately: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/4567"),
// IsInvoiced: to.Ptr(false),
// MarketplaceCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// UsageEnd: to.Ptr("2019-09-30"),
// UsageStart: to.Ptr("2019-09-01"),
// },
// },
// &armconsumption.ModernChargeSummary{
// Name: to.Ptr("chargeSummaryId2"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/67890/providers/Microsoft.Consumption/charges/chargeSummaryId2"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindModern),
// Properties: &armconsumption.ModernChargeSummaryProperties{
// AzureCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"),
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910"),
// BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"),
// ChargesBilledSeparately: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/4567"),
// IsInvoiced: to.Ptr(false),
// MarketplaceCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// UsageEnd: to.Ptr("2019-10-31"),
// UsageStart: to.Ptr("2019-09-01"),
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "chargeSummaryId1",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/67890/providers/Microsoft.Consumption/charges/chargeSummaryId1",
"kind": "modern",
"properties": {
"azureCharges": {
"currency": "USD",
"value": 5000
},
"billingAccountId": "/providers/Microsoft.Billing/billingAccounts/1234:56789",
"billingPeriodId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425",
"chargesBilledSeparately": {
"currency": "USD",
"value": 60.9
},
"invoiceSectionId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/4567",
"isInvoiced": false,
"marketplaceCharges": {
"currency": "USD",
"value": 100
},
"usageEnd": "2019-09-30",
"usageStart": "2019-09-01"
}
},
{
"name": "chargeSummaryId2",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/67890/providers/Microsoft.Consumption/charges/chargeSummaryId2",
"kind": "modern",
"properties": {
"azureCharges": {
"currency": "USD",
"value": 5000
},
"billingAccountId": "/providers/Microsoft.Billing/billingAccounts/1234:56789",
"billingPeriodId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425",
"chargesBilledSeparately": {
"currency": "USD",
"value": 60.9
},
"invoiceSectionId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/4567",
"isInvoiced": false,
"marketplaceCharges": {
"currency": "USD",
"value": 100
},
"usageEnd": "2019-10-31",
"usageStart": "2019-09-01"
}
}
]
}
ChargesListByCustomer-Modern
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234:56789/customers/67890/providers/Microsoft.Consumption/charges?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python charges_list_by_modern_customer.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.charges.list(
scope="providers/Microsoft.Billing/BillingAccounts/1234:56789/customers/67890",
)
print(response)
# x-ms-original-file: 2024-08-01/ChargesListByModernCustomer.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ChargesListByModernCustomer.json
func ExampleChargesClient_List_chargesListByCustomerModern() {
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)
}
res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/BillingAccounts/1234:56789/customers/67890", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armconsumption.ChargesClientListResponse{
// ChargesListResult: &armconsumption.ChargesListResult{
// Value: []armconsumption.ChargeSummaryClassification{
// &armconsumption.ModernChargeSummary{
// Name: to.Ptr("chargeSummaryId1"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/customers/67890/providers/Microsoft.Consumption/charges/chargeSummaryId1"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindModern),
// Properties: &armconsumption.ModernChargeSummaryProperties{
// AzureCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"),
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910"),
// ChargesBilledSeparately: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// IsInvoiced: to.Ptr(false),
// MarketplaceCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// UsageEnd: to.Ptr("2023-05-31"),
// UsageStart: to.Ptr("2023-03-01"),
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "chargeSummaryId1",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/billingAccounts/1234:56789/customers/67890/providers/Microsoft.Consumption/charges/chargeSummaryId1",
"kind": "modern",
"properties": {
"azureCharges": {
"currency": "USD",
"value": 0
},
"billingAccountId": "/providers/Microsoft.Billing/billingAccounts/1234:56789",
"billingPeriodId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910",
"billingProfileId": null,
"chargesBilledSeparately": {
"currency": "USD",
"value": 265.09
},
"invoiceSectionId": null,
"isInvoiced": false,
"marketplaceCharges": {
"currency": "USD",
"value": 0
},
"usageEnd": "2023-05-31",
"usageStart": "2023-03-01"
}
}
]
}
ChargesListByDepartment-Legacy
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234/departments/42425/providers/Microsoft.Consumption/charges?api-version=2024-08-01&$filter=usageStart eq '2018-04-01' AND usageEnd eq '2018-05-30'
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python charges_list_for_department_filter_by_start_end_date.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.charges.list(
scope="providers/Microsoft.Billing/BillingAccounts/1234/departments/42425",
)
print(response)
# x-ms-original-file: 2024-08-01/ChargesListForDepartmentFilterByStartEndDate.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ChargesListForDepartmentFilterByStartEndDate.json
func ExampleChargesClient_List_chargesListByDepartmentLegacy() {
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)
}
res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/BillingAccounts/1234/departments/42425", &armconsumption.ChargesClientListOptions{
Filter: to.Ptr("usageStart eq '2018-04-01' AND usageEnd eq '2018-05-30'")})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armconsumption.ChargesClientListResponse{
// ChargesListResult: &armconsumption.ChargesListResult{
// Value: []armconsumption.ChargeSummaryClassification{
// &armconsumption.LegacyChargeSummary{
// Name: to.Ptr("chargeSummaryId1"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/departments/42425/providers/Microsoft.Consumption/charges/chargeSummaryId1"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindLegacy),
// Properties: &armconsumption.LegacyChargeSummaryProperties{
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201804"),
// Currency: to.Ptr("USD"),
// UsageEnd: to.Ptr("2018-04-30"),
// UsageStart: to.Ptr("2018-04-01"),
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "chargeSummaryId1",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/BillingAccounts/1234/departments/42425/providers/Microsoft.Consumption/charges/chargeSummaryId1",
"kind": "legacy",
"properties": {
"azureCharges": 5000,
"azureMarketplaceCharges": 100,
"billingPeriodId": "/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201804",
"chargesBilledSeparately": 60.9,
"currency": "USD",
"usageEnd": "2018-04-30",
"usageStart": "2018-04-01"
}
}
]
}
ChargesListByInvoiceSectionId-Modern
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234:56789/invoiceSections/97531/providers/Microsoft.Consumption/charges?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python charges_list_by_modern_invoice_section_id.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.charges.list(
scope="providers/Microsoft.Billing/BillingAccounts/1234:56789/invoiceSections/97531",
)
print(response)
# x-ms-original-file: 2024-08-01/ChargesListByModernInvoiceSectionId.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ChargesListByModernInvoiceSectionId.json
func ExampleChargesClient_List_chargesListByInvoiceSectionIdModern() {
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)
}
res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/BillingAccounts/1234:56789/invoiceSections/97531", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armconsumption.ChargesClientListResponse{
// ChargesListResult: &armconsumption.ChargesListResult{
// Value: []armconsumption.ChargeSummaryClassification{
// &armconsumption.ModernChargeSummary{
// Name: to.Ptr("chargeSummaryId1"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460/invoiceSections/97531/providers/Microsoft.Consumption/charges/chargeSummaryId1"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindModern),
// Properties: &armconsumption.ModernChargeSummaryProperties{
// AzureCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"),
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910"),
// BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460"),
// ChargesBilledSeparately: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460/invoiceSections/97531"),
// IsInvoiced: to.Ptr(false),
// MarketplaceCharges: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// UsageEnd: to.Ptr("2023-05-31"),
// UsageStart: to.Ptr("2023-03-01"),
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "chargeSummaryId1",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460/invoiceSections/97531/providers/Microsoft.Consumption/charges/chargeSummaryId1",
"kind": "modern",
"properties": {
"azureCharges": {
"currency": "USD",
"value": 12
},
"billingAccountId": "/providers/Microsoft.Billing/billingAccounts/1234:56789",
"billingPeriodId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910",
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460",
"chargesBilledSeparately": {
"currency": "USD",
"value": 0
},
"invoiceSectionId": "/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460/invoiceSections/97531",
"isInvoiced": false,
"marketplaceCharges": {
"currency": "USD",
"value": 0
},
"usageEnd": "2023-05-31",
"usageStart": "2023-03-01"
}
}
]
}
ChargesListForEnrollmentAccount-Legacy
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/BillingAccounts/1234/enrollmentAccounts/42425/providers/Microsoft.Consumption/charges?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python charges_list_for_enrollment_account_filter_by_start_end_date.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.charges.list(
scope="providers/Microsoft.Billing/BillingAccounts/1234/enrollmentAccounts/42425",
)
print(response)
# x-ms-original-file: 2024-08-01/ChargesListForEnrollmentAccountFilterByStartEndDate.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ChargesListForEnrollmentAccountFilterByStartEndDate.json
func ExampleChargesClient_List_chargesListForEnrollmentAccountLegacy() {
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)
}
res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/BillingAccounts/1234/enrollmentAccounts/42425", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armconsumption.ChargesClientListResponse{
// ChargesListResult: &armconsumption.ChargesListResult{
// Value: []armconsumption.ChargeSummaryClassification{
// &armconsumption.LegacyChargeSummary{
// Name: to.Ptr("chargeSummaryId1"),
// Type: to.Ptr("Microsoft.Consumption/charges"),
// ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/enrollmentAccounts/42425/providers/Microsoft.Consumption/charges/chargeSummaryId1"),
// Kind: to.Ptr(armconsumption.ChargeSummaryKindLegacy),
// Properties: &armconsumption.LegacyChargeSummaryProperties{
// BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201804"),
// Currency: to.Ptr("USD"),
// UsageEnd: to.Ptr("2018-04-30"),
// UsageStart: to.Ptr("2018-04-01"),
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"value": [
{
"name": "chargeSummaryId1",
"type": "Microsoft.Consumption/charges",
"id": "/providers/Microsoft.Billing/BillingAccounts/1234/enrollmentAccounts/42425/providers/Microsoft.Consumption/charges/chargeSummaryId1",
"kind": "legacy",
"properties": {
"azureCharges": 5000,
"azureMarketplaceCharges": 100,
"billingPeriodId": "/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201804",
"chargesBilledSeparately": 60.9,
"currency": "USD",
"usageEnd": "2018-04-30",
"usageStart": "2018-04-01"
}
}
]
}
Definitions
amount
Object
The amount plus currency .
| Name |
Type |
Description |
|
currency
|
string
|
Amount currency.
|
|
value
|
number
(decimal)
|
Amount.
|
ChargesListResult
Object
Result of listing charge summary.
| Name |
Type |
Description |
|
value
|
ChargeSummary[]:
|
The list of charge summary
|
ChargeSummaryKind
Enumeration
Specifies the kind of charge summary.
| Value |
Description |
|
legacy
|
|
|
modern
|
|
createdByType
Enumeration
The type of identity that created the resource.
| Value |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
ErrorAdditionalInfo
Object
The resource management error additional info.
| Name |
Type |
Description |
|
info
|
object
|
The additional info.
|
|
type
|
string
|
The additional info type.
|
ErrorDetail
Object
The error detail.
| Name |
Type |
Description |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
The error additional info.
|
|
code
|
string
|
The error code.
|
|
details
|
ErrorDetail[]
|
The error details.
|
|
message
|
string
|
The error message.
|
|
target
|
string
|
The error target.
|
ErrorResponse
Object
Error response
| Name |
Type |
Description |
|
error
|
ErrorDetail
|
The error object.
|
LegacyChargeSummary
Object
Legacy charge summary.
| Name |
Type |
Description |
|
eTag
|
string
|
eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.
|
|
id
|
string
|
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
kind
|
string:
legacy
|
Specifies the kind of charge summary.
|
|
name
|
string
|
The name of the resource
|
|
properties.azureCharges
|
number
(decimal)
|
Azure Charges.
|
|
properties.azureMarketplaceCharges
|
number
(decimal)
|
Marketplace Charges.
|
|
properties.billingPeriodId
|
string
|
The id of the billing period resource that the charge belongs to.
|
|
properties.chargesBilledSeparately
|
number
(decimal)
|
Charges Billed separately.
|
|
properties.currency
|
string
|
Currency Code
|
|
properties.usageEnd
|
string
|
Usage end date.
|
|
properties.usageStart
|
string
|
Usage start date.
|
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
ModernChargeSummary
Object
Modern charge summary.
| Name |
Type |
Description |
|
eTag
|
string
|
eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.
|
|
id
|
string
|
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
kind
|
string:
modern
|
Specifies the kind of charge summary.
|
|
name
|
string
|
The name of the resource
|
|
properties.azureCharges
|
amount
|
Azure Charges.
|
|
properties.billingAccountId
|
string
|
Billing Account Id
|
|
properties.billingPeriodId
|
string
|
The id of the billing period resource that the charge belongs to.
|
|
properties.billingProfileId
|
string
|
Billing Profile Id
|
|
properties.chargesBilledSeparately
|
amount
|
Charges Billed separately.
|
|
properties.customerId
|
string
|
Customer Id
|
|
properties.invoiceSectionId
|
string
|
Invoice Section Id
|
|
properties.isInvoiced
|
boolean
|
Is charge Invoiced
|
|
properties.marketplaceCharges
|
amount
|
Marketplace Charges.
|
|
properties.subscriptionId
|
string
|
Subscription guid.
|
|
properties.usageEnd
|
string
|
Usage end date.
|
|
properties.usageStart
|
string
|
Usage start date.
|
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
systemData
Object
Metadata pertaining to creation and last modification of the resource.
| Name |
Type |
Description |
|
createdAt
|
string
(date-time)
|
The timestamp of resource creation (UTC).
|
|
createdBy
|
string
|
The identity that created the resource.
|
|
createdByType
|
createdByType
|
The type of identity that created the resource.
|
|
lastModifiedAt
|
string
(date-time)
|
The timestamp of resource last modification (UTC)
|
|
lastModifiedBy
|
string
|
The identity that last modified the resource.
|
|
lastModifiedByType
|
createdByType
|
The type of identity that last modified the resource.
|