Enumera los cargos basados en el ámbito definido.
GET https://management.azure.com/{scope}/providers/Microsoft.Consumption/charges?api-version=2024-08-01
Con parámetros opcionales:
GET https://management.azure.com/{scope}/providers/Microsoft.Consumption/charges?api-version=2024-08-01&startDate={startDate}&endDate={endDate}&$filter={$filter}&$apply={$apply}
Parámetros de identificador URI
| Nombre |
En |
Requerido |
Tipo |
Description |
|
scope
|
path |
True
|
string
|
Identificador completo de Azure Resource Manager del recurso.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
La versión de API que se va a utilizar para esta operación.
|
|
$apply
|
query |
|
string
|
Puede usarse para agrupar los cargos para el ámbito billingAccount por propiedades/billingProfileId, properties/invoiceSectionId, properties/customerId (específico para partner Led) o para el ámbito billingProfile por properties/invoiceSectionId.
|
|
$filter
|
query |
|
string
|
Puede usarse para filtrar los cargos por propiedades/usageEnd (hora Utc), properties/usageStart (hora Utc). El filtro admite 'eq', 'lt', 'gt', 'le', 'ge' y 'and'. Actualmente no admite 'ne', 'or' o 'not'. El filtro de etiquetas es una cadena de par clave-valor donde la clave y el valor están separados por dos puntos (:).
|
|
endDate
|
query |
|
string
|
Fecha de finalización
|
|
startDate
|
query |
|
string
|
Fecha de inicio
|
Respuestas
| Nombre |
Tipo |
Description |
|
200 OK
|
ChargesListResult
|
La solicitud se ha realizado correctamente.
|
|
Other Status Codes
|
ErrorResponse
|
Una respuesta de error inesperada.
|
Seguridad
azure_auth
Flujo de OAuth2 de Azure Active Directory.
Tipo:
oauth2
Flujo:
implicit
Dirección URL de autorización:
https://login.microsoftonline.com/common/oauth2/authorize
Ámbitos
| Nombre |
Description |
|
user_impersonation
|
suplantar la cuenta de usuario
|
Ejemplos
ChangesForBillingPeriodByDepartment-Legacy
Solicitud de ejemplo
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
Respuesta de muestra
{
"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
Solicitud de ejemplo
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
Respuesta de muestra
{
"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
Solicitud de ejemplo
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
Respuesta de muestra
{
"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
Solicitud de ejemplo
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
Respuesta de muestra
{
"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
Solicitud de ejemplo
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
Respuesta de muestra
{
"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
Solicitud de ejemplo
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
Respuesta de muestra
{
"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
Solicitud de ejemplo
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
Respuesta de muestra
{
"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
Solicitud de ejemplo
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
Respuesta de muestra
{
"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
Solicitud de ejemplo
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
Respuesta de muestra
{
"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
Solicitud de ejemplo
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
Respuesta de muestra
{
"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
Solicitud de ejemplo
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
Respuesta de muestra
{
"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
Solicitud de ejemplo
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
Respuesta de muestra
{
"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
Solicitud de ejemplo
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
Respuesta de muestra
{
"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"
}
}
]
}
Definiciones
amount
Objeto
Cantidad más moneda .
| Nombre |
Tipo |
Description |
|
currency
|
string
|
Moneda de importe.
|
|
value
|
number
(decimal)
|
Importe.
|
ChargesListResult
Objeto
Resultado del resumen de cargos de la lista.
| Nombre |
Tipo |
Description |
|
value
|
ChargeSummary[]:
|
La lista de resumen de cargos
|
ChargeSummaryKind
Enumeración
Especifica el tipo de resumen de cargos.
| Valor |
Description |
|
legacy
|
|
|
modern
|
|
createdByType
Enumeración
Tipo de identidad que creó el recurso.
| Valor |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
ErrorAdditionalInfo
Objeto
Información adicional sobre el error de administración de recursos.
| Nombre |
Tipo |
Description |
|
info
|
object
|
Información adicional.
|
|
type
|
string
|
Tipo de información adicional.
|
ErrorDetail
Objeto
Detalle del error.
| Nombre |
Tipo |
Description |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
Información adicional del error.
|
|
code
|
string
|
Código de error.
|
|
details
|
ErrorDetail[]
|
Detalles del error.
|
|
message
|
string
|
El mensaje de error.
|
|
target
|
string
|
Destino del error.
|
ErrorResponse
Objeto
Respuesta de error
| Nombre |
Tipo |
Description |
|
error
|
ErrorDetail
|
Objeto de error.
|
LegacyChargeSummary
Objeto
Resumen de cargos heredados.
| Nombre |
Tipo |
Description |
|
eTag
|
string
|
eTag del recurso. Para controlar el escenario de actualización simultánea, este campo se usará para determinar si el usuario está actualizando la versión más reciente o no.
|
|
id
|
string
|
Identificador de recurso completo para el recurso. Ej: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
kind
|
string:
legacy
|
Especifica el tipo de resumen de cargos.
|
|
name
|
string
|
Nombre del recurso
|
|
properties.azureCharges
|
number
(decimal)
|
Cargos de Azure.
|
|
properties.azureMarketplaceCharges
|
number
(decimal)
|
Cargos de Marketplace.
|
|
properties.billingPeriodId
|
string
|
Identificador del recurso del período de facturación al que pertenece el cargo.
|
|
properties.chargesBilledSeparately
|
number
(decimal)
|
Cargos facturados por separado.
|
|
properties.currency
|
string
|
Cód. divisa
|
|
properties.usageEnd
|
string
|
Fecha de finalización del uso.
|
|
properties.usageStart
|
string
|
Fecha de inicio del uso.
|
|
systemData
|
systemData
|
Metadatos de Azure Resource Manager que contienen información createdBy y modifiedBy.
|
|
type
|
string
|
Tipo de recurso. Por ejemplo, "Microsoft.Compute/virtualMachines" o "Microsoft.Storage/storageAccounts"
|
ModernChargeSummary
Objeto
Resumen de cargos modernos.
| Nombre |
Tipo |
Description |
|
eTag
|
string
|
eTag del recurso. Para controlar el escenario de actualización simultánea, este campo se usará para determinar si el usuario está actualizando la versión más reciente o no.
|
|
id
|
string
|
Identificador de recurso completo para el recurso. Ej: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
kind
|
string:
modern
|
Especifica el tipo de resumen de cargos.
|
|
name
|
string
|
Nombre del recurso
|
|
properties.azureCharges
|
amount
|
Cargos de Azure.
|
|
properties.billingAccountId
|
string
|
Identificador de cuenta de facturación
|
|
properties.billingPeriodId
|
string
|
Identificador del recurso del período de facturación al que pertenece el cargo.
|
|
properties.billingProfileId
|
string
|
Id. de perfil de facturación
|
|
properties.chargesBilledSeparately
|
amount
|
Cargos facturados por separado.
|
|
properties.customerId
|
string
|
Id. de cliente
|
|
properties.invoiceSectionId
|
string
|
Id. de sección de factura
|
|
properties.isInvoiced
|
boolean
|
Se factura el cargo
|
|
properties.marketplaceCharges
|
amount
|
Cargos de Marketplace.
|
|
properties.subscriptionId
|
string
|
Guid de suscripción.
|
|
properties.usageEnd
|
string
|
Fecha de finalización del uso.
|
|
properties.usageStart
|
string
|
Fecha de inicio del uso.
|
|
systemData
|
systemData
|
Metadatos de Azure Resource Manager que contienen información createdBy y modifiedBy.
|
|
type
|
string
|
Tipo de recurso. Por ejemplo, "Microsoft.Compute/virtualMachines" o "Microsoft.Storage/storageAccounts"
|
systemData
Objeto
Metadatos relativos a la creación y última modificación del recurso.
| Nombre |
Tipo |
Description |
|
createdAt
|
string
(date-time)
|
Marca de tiempo de creación de recursos (UTC).
|
|
createdBy
|
string
|
Identidad que creó el recurso.
|
|
createdByType
|
createdByType
|
Tipo de identidad que creó el recurso.
|
|
lastModifiedAt
|
string
(date-time)
|
La marca de tiempo de la última modificación del recurso (UTC)
|
|
lastModifiedBy
|
string
|
La identidad que modificó por última vez el recurso.
|
|
lastModifiedByType
|
createdByType
|
El tipo de identidad que modificó por última vez el recurso.
|