Operación para crear o actualizar una exportación. La operación de actualización requiere que se establezca eTag más reciente en la solicitud. Puede obtener la eTag más reciente realizando una operación get. La operación de creación no requiere eTag.
PUT https://management.azure.com/{scope}/providers/Microsoft.CostManagement/exports/{exportName}?api-version=2025-03-01
Parámetros de identificador URI
| Nombre |
En |
Requerido |
Tipo |
Description |
|
exportName
|
path |
True
|
string
|
Nombre de exportación.
|
|
scope
|
path |
True
|
string
|
Identificador completo de Azure Resource Manager del recurso.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
Versión de la API que se va a usar para esta operación.
|
Cuerpo de la solicitud
| Nombre |
Requerido |
Tipo |
Description |
|
properties.definition
|
True
|
ExportDefinition
|
Tiene la definición de la exportación.
|
|
properties.deliveryInfo
|
True
|
ExportDeliveryInfo
|
Tiene información de entrega para la exportación.
|
|
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.
|
|
identity
|
|
SystemAssignedServiceIdentity
|
Identidad administrada asociada a Export
|
|
location
|
|
string
|
Ubicación de la identidad administrada de la exportación. Solo es necesario al usar la identidad administrada.
|
|
properties.compressionMode
|
|
CompressionModeType
|
Permitir que los clientes seleccionen comprimir datos para las exportaciones. Esta configuración habilitará el esquema de compresión de archivos de destino en tiempo de ejecución. De forma predeterminada, establezca en Ninguno. Gzip es para csv y snappy para parquet.
|
|
properties.dataOverwriteBehavior
|
|
DataOverwriteBehaviorType
|
Permitir que los clientes seleccionen sobrescribir datos (OverwritePreviousReport) para las exportaciones. Esta configuración habilitará la sobrescritura de datos para el mismo mes en la cuenta de almacenamiento del cliente. De forma predeterminada, establezca en CreateNewReport.
|
|
properties.exportDescription
|
|
string
|
Descripción de exportación establecida por el cliente en el momento de la creación o actualización de la exportación.
|
|
properties.format
|
|
FormatType
|
Formato de la exportación que se va a entregar.
|
|
properties.partitionData
|
|
boolean
|
Si se establece en true, los datos exportados se particionarán por tamaño y se colocarán en un directorio de blobs junto con un archivo de manifiesto.
|
|
properties.runHistory
|
|
ExportExecutionListResult
|
Si se solicita, tiene el historial de ejecución más reciente para la exportación.
|
|
properties.schedule
|
|
ExportSchedule
|
Tiene información de programación para la exportación.
|
Respuestas
| Nombre |
Tipo |
Description |
|
200 OK
|
Export
|
Operación de actualización 'Export' de recursos exitosa
|
|
201 Created
|
Export
|
Operación de creación de recurso 'Exportar' exitosa
|
|
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
ExportCreateOrUpdateByBillingAccount
Solicitud de ejemplo
PUT https://management.azure.com/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport?api-version=2025-03-01
{
"identity": {
"type": "SystemAssigned"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"type": "AzureBlob",
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.costmanagement import CostManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-costmanagement
# USAGE
python export_create_or_update_by_billing_account.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = CostManagementClient(
credential=DefaultAzureCredential(),
)
response = client.exports.create_or_update(
scope="providers/Microsoft.Billing/billingAccounts/123456",
export_name="TestExport",
parameters={
"identity": {"type": "SystemAssigned"},
"location": "centralus",
"properties": {
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"dataSet": {"configuration": {"dataVersion": "2023-05-01"}, "granularity": "Daily"},
"timeframe": "MonthToDate",
"type": "ActualCost",
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc",
"type": "AzureBlob",
}
},
"exportDescription": "This is a test export.",
"format": "Csv",
"partitionData": True,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {"from": "2020-06-01T00:00:00Z", "to": "2020-06-30T00:00:00Z"},
"status": "Active",
},
},
},
)
print(response)
# x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByBillingAccount.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 armcostmanagement_test
import (
"context"
"log"
"time"
"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/costmanagement/armcostmanagement/v3"
)
// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByBillingAccount.json
func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccount() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcostmanagement.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{
Identity: &armcostmanagement.SystemAssignedServiceIdentity{
Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
},
Location: to.Ptr("centralus"),
Properties: &armcostmanagement.ExportProperties{
Format: to.Ptr(armcostmanagement.FormatTypeCSV),
CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
Definition: &armcostmanagement.ExportDefinition{
Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
DataSet: &armcostmanagement.ExportDataset{
Configuration: &armcostmanagement.ExportDatasetConfiguration{
DataVersion: to.Ptr("2023-05-01"),
},
Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
},
Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
},
DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
Destination: &armcostmanagement.ExportDeliveryDestination{
Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob),
Container: to.Ptr("exports"),
ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
RootFolderPath: to.Ptr("ad-hoc"),
},
},
ExportDescription: to.Ptr("This is a test export."),
PartitionData: to.Ptr(true),
Schedule: &armcostmanagement.ExportSchedule{
Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()),
To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t }()),
},
Status: to.Ptr(armcostmanagement.StatusTypeActive),
},
},
}, 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 = armcostmanagement.ExportsClientCreateOrUpdateResponse{
// Export: armcostmanagement.Export{
// Name: to.Ptr("TestExport"),
// Type: to.Ptr("Microsoft.CostManagement/exports"),
// ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"),
// Identity: &armcostmanagement.SystemAssignedServiceIdentity{
// Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// Location: to.Ptr("centralus"),
// Properties: &armcostmanagement.ExportProperties{
// Format: to.Ptr(armcostmanagement.FormatTypeCSV),
// CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
// DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
// Definition: &armcostmanagement.ExportDefinition{
// Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
// DataSet: &armcostmanagement.ExportDataset{
// Configuration: &armcostmanagement.ExportDatasetConfiguration{
// DataVersion: to.Ptr("2023-05-01"),
// },
// Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
// },
// Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
// },
// DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
// Destination: &armcostmanagement.ExportDeliveryDestination{
// Container: to.Ptr("exports"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
// RootFolderPath: to.Ptr("ad-hoc"),
// },
// },
// ExportDescription: to.Ptr("This is a test export."),
// NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T23:00:00Z"); return t}()),
// PartitionData: to.Ptr(true),
// Schedule: &armcostmanagement.ExportSchedule{
// Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
// RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
// From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()),
// To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()),
// },
// Status: to.Ptr(armcostmanagement.StatusTypeActive),
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CostManagementClient } = require("@azure/arm-costmanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
*
* @summary the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
* x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByBillingAccount.json
*/
async function exportCreateOrUpdateByBillingAccount() {
const credential = new DefaultAzureCredential();
const client = new CostManagementClient(credential);
const result = await client.exports.createOrUpdate(
"providers/Microsoft.Billing/billingAccounts/123456",
"TestExport",
{
identity: { type: "SystemAssigned" },
location: "centralus",
format: "Csv",
compressionMode: "gzip",
dataOverwriteBehavior: "OverwritePreviousReport",
definition: {
type: "ActualCost",
dataSet: { configuration: { dataVersion: "2023-05-01" }, granularity: "Daily" },
timeframe: "MonthToDate",
},
deliveryInfo: {
destination: {
type: "AzureBlob",
container: "exports",
resourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
rootFolderPath: "ad-hoc",
},
},
exportDescription: "This is a test export.",
partitionData: true,
schedule: {
recurrence: "Daily",
recurrencePeriod: {
from: new Date("2020-06-01T00:00:00Z"),
to: new Date("2020-06-30T00:00:00Z"),
},
status: "Active",
},
},
);
console.log(result);
}
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
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2020-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2020-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
ExportCreateOrUpdateByBillingAccountCustom
Solicitud de ejemplo
PUT https://management.azure.com/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport?api-version=2025-03-01
{
"identity": {
"type": "SystemAssigned"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timePeriod": {
"from": "2025-04-03T00:00:00.000Z",
"to": "2025-04-03T00:00:00.000Z"
},
"timeframe": "Custom"
},
"deliveryInfo": {
"destination": {
"type": "AzureBlob",
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"partitionData": true,
"schedule": {
"status": "Inactive"
}
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.costmanagement import CostManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-costmanagement
# USAGE
python export_create_or_update_by_billing_account_custom.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 = CostManagementClient(
credential=DefaultAzureCredential(),
)
response = client.exports.create_or_update(
scope="providers/Microsoft.Billing/billingAccounts/123456",
export_name="TestExport",
parameters={
"identity": {"type": "SystemAssigned"},
"location": "centralus",
"properties": {
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"dataSet": {"configuration": {"dataVersion": "2023-05-01"}, "granularity": "Daily"},
"timePeriod": {"from": "2025-04-03T00:00:00.000Z", "to": "2025-04-03T00:00:00.000Z"},
"timeframe": "Custom",
"type": "ActualCost",
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc",
"type": "AzureBlob",
}
},
"exportDescription": "This is a test export.",
"format": "Csv",
"partitionData": True,
"schedule": {"status": "Inactive"},
},
},
)
print(response)
# x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByBillingAccountCustom.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 armcostmanagement_test
import (
"context"
"log"
"time"
"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/costmanagement/armcostmanagement/v3"
)
// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByBillingAccountCustom.json
func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccountCustom() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcostmanagement.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{
Identity: &armcostmanagement.SystemAssignedServiceIdentity{
Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
},
Location: to.Ptr("centralus"),
Properties: &armcostmanagement.ExportProperties{
Format: to.Ptr(armcostmanagement.FormatTypeCSV),
CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
Definition: &armcostmanagement.ExportDefinition{
Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
DataSet: &armcostmanagement.ExportDataset{
Configuration: &armcostmanagement.ExportDatasetConfiguration{
DataVersion: to.Ptr("2023-05-01"),
},
Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
},
TimePeriod: &armcostmanagement.ExportTimePeriod{
From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-03T00:00:00.000Z"); return t }()),
To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-03T00:00:00.000Z"); return t }()),
},
Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom),
},
DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
Destination: &armcostmanagement.ExportDeliveryDestination{
Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob),
Container: to.Ptr("exports"),
ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
RootFolderPath: to.Ptr("ad-hoc"),
},
},
ExportDescription: to.Ptr("This is a test export."),
PartitionData: to.Ptr(true),
Schedule: &armcostmanagement.ExportSchedule{
Status: to.Ptr(armcostmanagement.StatusTypeInactive),
},
},
}, 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 = armcostmanagement.ExportsClientCreateOrUpdateResponse{
// Export: armcostmanagement.Export{
// Name: to.Ptr("TestExport"),
// Type: to.Ptr("Microsoft.CostManagement/exports"),
// ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"),
// Identity: &armcostmanagement.SystemAssignedServiceIdentity{
// Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// Location: to.Ptr("centralus"),
// Properties: &armcostmanagement.ExportProperties{
// Format: to.Ptr(armcostmanagement.FormatTypeCSV),
// CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
// DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
// Definition: &armcostmanagement.ExportDefinition{
// Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
// DataSet: &armcostmanagement.ExportDataset{
// Configuration: &armcostmanagement.ExportDatasetConfiguration{
// DataVersion: to.Ptr("2023-05-01"),
// },
// Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
// },
// TimePeriod: &armcostmanagement.ExportTimePeriod{
// From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-03T00:00:00Z"); return t}()),
// To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-03T00:00:00Z"); return t}()),
// },
// Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom),
// },
// DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
// Destination: &armcostmanagement.ExportDeliveryDestination{
// Container: to.Ptr("exports"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
// RootFolderPath: to.Ptr("ad-hoc"),
// },
// },
// ExportDescription: to.Ptr("This is a test export."),
// PartitionData: to.Ptr(true),
// Schedule: &armcostmanagement.ExportSchedule{
// Recurrence: to.Ptr(armcostmanagement.RecurrenceType("None")),
// Status: to.Ptr(armcostmanagement.StatusTypeInactive),
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CostManagementClient } = require("@azure/arm-costmanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
*
* @summary the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
* x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByBillingAccountCustom.json
*/
async function exportCreateOrUpdateByBillingAccountCustom() {
const credential = new DefaultAzureCredential();
const client = new CostManagementClient(credential);
const result = await client.exports.createOrUpdate(
"providers/Microsoft.Billing/billingAccounts/123456",
"TestExport",
{
identity: { type: "SystemAssigned" },
location: "centralus",
format: "Csv",
compressionMode: "gzip",
dataOverwriteBehavior: "OverwritePreviousReport",
definition: {
type: "ActualCost",
dataSet: { configuration: { dataVersion: "2023-05-01" }, granularity: "Daily" },
timePeriod: {
from: new Date("2025-04-03T00:00:00.000Z"),
to: new Date("2025-04-03T00:00:00.000Z"),
},
timeframe: "Custom",
},
deliveryInfo: {
destination: {
type: "AzureBlob",
container: "exports",
resourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
rootFolderPath: "ad-hoc",
},
},
exportDescription: "This is a test export.",
partitionData: true,
schedule: { status: "Inactive" },
},
);
console.log(result);
}
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
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timePeriod": {
"from": "2025-04-03T00:00:00Z",
"to": "2025-04-03T00:00:00Z"
},
"timeframe": "Custom"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"partitionData": true,
"schedule": {
"recurrence": "None",
"status": "Inactive"
}
}
}
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timePeriod": {
"from": "2025-04-03T00:00:00Z",
"to": "2025-04-03T00:00:00Z"
},
"timeframe": "Custom"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"partitionData": true,
"schedule": {
"recurrence": "None",
"status": "Inactive"
}
}
}
ExportCreateOrUpdateByBillingAccountMonthly
Solicitud de ejemplo
PUT https://management.azure.com/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport?api-version=2025-03-01
{
"identity": {
"type": "SystemAssigned"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "TheLastMonth"
},
"deliveryInfo": {
"destination": {
"type": "AzureBlob",
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"partitionData": true,
"schedule": {
"recurrence": "Monthly",
"recurrencePeriod": {
"from": "2020-06-05T00:00:00Z",
"to": "2030-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.costmanagement import CostManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-costmanagement
# USAGE
python export_create_or_update_by_billing_account_monthly.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 = CostManagementClient(
credential=DefaultAzureCredential(),
)
response = client.exports.create_or_update(
scope="providers/Microsoft.Billing/billingAccounts/123456",
export_name="TestExport",
parameters={
"identity": {"type": "SystemAssigned"},
"location": "centralus",
"properties": {
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"dataSet": {"configuration": {"dataVersion": "2023-05-01"}, "granularity": "Daily"},
"timeframe": "TheLastMonth",
"type": "ActualCost",
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc",
"type": "AzureBlob",
}
},
"exportDescription": "This is a test export.",
"format": "Csv",
"partitionData": True,
"schedule": {
"recurrence": "Monthly",
"recurrencePeriod": {"from": "2020-06-05T00:00:00Z", "to": "2030-06-30T00:00:00Z"},
"status": "Active",
},
},
},
)
print(response)
# x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByBillingAccountMonthly.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 armcostmanagement_test
import (
"context"
"log"
"time"
"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/costmanagement/armcostmanagement/v3"
)
// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByBillingAccountMonthly.json
func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccountMonthly() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcostmanagement.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{
Identity: &armcostmanagement.SystemAssignedServiceIdentity{
Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
},
Location: to.Ptr("centralus"),
Properties: &armcostmanagement.ExportProperties{
Format: to.Ptr(armcostmanagement.FormatTypeCSV),
CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
Definition: &armcostmanagement.ExportDefinition{
Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
DataSet: &armcostmanagement.ExportDataset{
Configuration: &armcostmanagement.ExportDatasetConfiguration{
DataVersion: to.Ptr("2023-05-01"),
},
Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
},
Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth),
},
DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
Destination: &armcostmanagement.ExportDeliveryDestination{
Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob),
Container: to.Ptr("exports"),
ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
RootFolderPath: to.Ptr("ad-hoc"),
},
},
ExportDescription: to.Ptr("This is a test export."),
PartitionData: to.Ptr(true),
Schedule: &armcostmanagement.ExportSchedule{
Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeMonthly),
RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T00:00:00Z"); return t }()),
To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2030-06-30T00:00:00Z"); return t }()),
},
Status: to.Ptr(armcostmanagement.StatusTypeActive),
},
},
}, 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 = armcostmanagement.ExportsClientCreateOrUpdateResponse{
// Export: armcostmanagement.Export{
// Name: to.Ptr("TestExport"),
// Type: to.Ptr("Microsoft.CostManagement/exports"),
// ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"),
// Identity: &armcostmanagement.SystemAssignedServiceIdentity{
// Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// Location: to.Ptr("centralus"),
// Properties: &armcostmanagement.ExportProperties{
// Format: to.Ptr(armcostmanagement.FormatTypeCSV),
// CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
// DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
// Definition: &armcostmanagement.ExportDefinition{
// Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
// DataSet: &armcostmanagement.ExportDataset{
// Configuration: &armcostmanagement.ExportDatasetConfiguration{
// DataVersion: to.Ptr("2023-05-01"),
// },
// Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
// },
// Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth),
// },
// DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
// Destination: &armcostmanagement.ExportDeliveryDestination{
// Container: to.Ptr("exports"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
// RootFolderPath: to.Ptr("ad-hoc"),
// },
// },
// ExportDescription: to.Ptr("This is a test export."),
// NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T23:00:00Z"); return t}()),
// PartitionData: to.Ptr(true),
// Schedule: &armcostmanagement.ExportSchedule{
// Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeMonthly),
// RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
// From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T00:00:00Z"); return t}()),
// To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2030-06-30T00:00:00Z"); return t}()),
// },
// Status: to.Ptr(armcostmanagement.StatusTypeActive),
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CostManagementClient } = require("@azure/arm-costmanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
*
* @summary the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
* x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByBillingAccountMonthly.json
*/
async function exportCreateOrUpdateByBillingAccountMonthly() {
const credential = new DefaultAzureCredential();
const client = new CostManagementClient(credential);
const result = await client.exports.createOrUpdate(
"providers/Microsoft.Billing/billingAccounts/123456",
"TestExport",
{
identity: { type: "SystemAssigned" },
location: "centralus",
format: "Csv",
compressionMode: "gzip",
dataOverwriteBehavior: "OverwritePreviousReport",
definition: {
type: "ActualCost",
dataSet: { configuration: { dataVersion: "2023-05-01" }, granularity: "Daily" },
timeframe: "TheLastMonth",
},
deliveryInfo: {
destination: {
type: "AzureBlob",
container: "exports",
resourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
rootFolderPath: "ad-hoc",
},
},
exportDescription: "This is a test export.",
partitionData: true,
schedule: {
recurrence: "Monthly",
recurrencePeriod: {
from: new Date("2020-06-05T00:00:00Z"),
to: new Date("2030-06-30T00:00:00Z"),
},
status: "Active",
},
},
);
console.log(result);
}
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
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "TheLastMonth"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2020-06-05T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Monthly",
"recurrencePeriod": {
"from": "2020-06-05T00:00:00Z",
"to": "2030-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "TheLastMonth"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2020-06-05T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Monthly",
"recurrencePeriod": {
"from": "2020-06-05T00:00:00Z",
"to": "2030-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
ExportCreateOrUpdateByBillingAccountPricesheet
Solicitud de ejemplo
PUT https://management.azure.com/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport?api-version=2025-03-01
{
"identity": {
"type": "SystemAssigned"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "PriceSheet",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "TheCurrentMonth"
},
"deliveryInfo": {
"destination": {
"type": "AzureBlob",
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2023-06-01T00:00:00Z",
"to": "2023-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.costmanagement import CostManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-costmanagement
# USAGE
python export_create_or_update_by_billing_account_pricesheet.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 = CostManagementClient(
credential=DefaultAzureCredential(),
)
response = client.exports.create_or_update(
scope="providers/Microsoft.Billing/billingAccounts/123456",
export_name="TestExport",
parameters={
"identity": {"type": "SystemAssigned"},
"location": "centralus",
"properties": {
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"dataSet": {"configuration": {"dataVersion": "2023-05-01"}, "granularity": "Daily"},
"timeframe": "TheCurrentMonth",
"type": "PriceSheet",
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc",
"type": "AzureBlob",
}
},
"exportDescription": "This is a test export.",
"format": "Csv",
"partitionData": True,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {"from": "2023-06-01T00:00:00Z", "to": "2023-06-30T00:00:00Z"},
"status": "Active",
},
},
},
)
print(response)
# x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByBillingAccountPricesheet.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 armcostmanagement_test
import (
"context"
"log"
"time"
"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/costmanagement/armcostmanagement/v3"
)
// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByBillingAccountPricesheet.json
func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccountPricesheet() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcostmanagement.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{
Identity: &armcostmanagement.SystemAssignedServiceIdentity{
Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
},
Location: to.Ptr("centralus"),
Properties: &armcostmanagement.ExportProperties{
Format: to.Ptr(armcostmanagement.FormatTypeCSV),
CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
Definition: &armcostmanagement.ExportDefinition{
Type: to.Ptr(armcostmanagement.ExportTypePriceSheet),
DataSet: &armcostmanagement.ExportDataset{
Configuration: &armcostmanagement.ExportDatasetConfiguration{
DataVersion: to.Ptr("2023-05-01"),
},
Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
},
Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheCurrentMonth),
},
DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
Destination: &armcostmanagement.ExportDeliveryDestination{
Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob),
Container: to.Ptr("exports"),
ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
RootFolderPath: to.Ptr("ad-hoc"),
},
},
ExportDescription: to.Ptr("This is a test export."),
PartitionData: to.Ptr(true),
Schedule: &armcostmanagement.ExportSchedule{
Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t }()),
To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); return t }()),
},
Status: to.Ptr(armcostmanagement.StatusTypeActive),
},
},
}, 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 = armcostmanagement.ExportsClientCreateOrUpdateResponse{
// Export: armcostmanagement.Export{
// Name: to.Ptr("TestExport"),
// Type: to.Ptr("Microsoft.CostManagement/exports"),
// ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"),
// Identity: &armcostmanagement.SystemAssignedServiceIdentity{
// Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// Location: to.Ptr("centralus"),
// Properties: &armcostmanagement.ExportProperties{
// Format: to.Ptr(armcostmanagement.FormatTypeCSV),
// CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
// DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
// Definition: &armcostmanagement.ExportDefinition{
// Type: to.Ptr(armcostmanagement.ExportTypePriceSheet),
// DataSet: &armcostmanagement.ExportDataset{
// Configuration: &armcostmanagement.ExportDatasetConfiguration{
// DataVersion: to.Ptr("2023-05-01"),
// },
// Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
// },
// Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheCurrentMonth),
// },
// DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
// Destination: &armcostmanagement.ExportDeliveryDestination{
// Container: to.Ptr("exports"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
// RootFolderPath: to.Ptr("ad-hoc"),
// },
// },
// ExportDescription: to.Ptr("This is a test export."),
// NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T23:00:00Z"); return t}()),
// PartitionData: to.Ptr(true),
// Schedule: &armcostmanagement.ExportSchedule{
// Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
// RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
// From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t}()),
// To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); return t}()),
// },
// Status: to.Ptr(armcostmanagement.StatusTypeActive),
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CostManagementClient } = require("@azure/arm-costmanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
*
* @summary the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
* x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByBillingAccountPricesheet.json
*/
async function exportCreateOrUpdateByBillingAccountPricesheet() {
const credential = new DefaultAzureCredential();
const client = new CostManagementClient(credential);
const result = await client.exports.createOrUpdate(
"providers/Microsoft.Billing/billingAccounts/123456",
"TestExport",
{
identity: { type: "SystemAssigned" },
location: "centralus",
format: "Csv",
compressionMode: "gzip",
dataOverwriteBehavior: "OverwritePreviousReport",
definition: {
type: "PriceSheet",
dataSet: { configuration: { dataVersion: "2023-05-01" }, granularity: "Daily" },
timeframe: "TheCurrentMonth",
},
deliveryInfo: {
destination: {
type: "AzureBlob",
container: "exports",
resourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
rootFolderPath: "ad-hoc",
},
},
exportDescription: "This is a test export.",
partitionData: true,
schedule: {
recurrence: "Daily",
recurrencePeriod: {
from: new Date("2023-06-01T00:00:00Z"),
to: new Date("2023-06-30T00:00:00Z"),
},
status: "Active",
},
},
);
console.log(result);
}
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
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "PriceSheet",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "TheCurrentMonth"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2023-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2023-06-01T00:00:00Z",
"to": "2023-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "PriceSheet",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "TheCurrentMonth"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2023-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2023-06-01T00:00:00Z",
"to": "2023-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
ExportCreateOrUpdateByBillingAccountReservationDetails
Solicitud de ejemplo
PUT https://management.azure.com/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport?api-version=2025-03-01
{
"identity": {
"type": "SystemAssigned"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ReservationDetails",
"dataSet": {
"configuration": {
"dataVersion": "2023-03-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"type": "AzureBlob",
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2023-06-01T00:00:00Z",
"to": "2023-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.costmanagement import CostManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-costmanagement
# USAGE
python export_create_or_update_by_billing_account_reservation_details.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 = CostManagementClient(
credential=DefaultAzureCredential(),
)
response = client.exports.create_or_update(
scope="providers/Microsoft.Billing/billingAccounts/123456",
export_name="TestExport",
parameters={
"identity": {"type": "SystemAssigned"},
"location": "centralus",
"properties": {
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"dataSet": {"configuration": {"dataVersion": "2023-03-01"}, "granularity": "Daily"},
"timeframe": "MonthToDate",
"type": "ReservationDetails",
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc",
"type": "AzureBlob",
}
},
"exportDescription": "This is a test export.",
"format": "Csv",
"partitionData": True,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {"from": "2023-06-01T00:00:00Z", "to": "2023-06-30T00:00:00Z"},
"status": "Active",
},
},
},
)
print(response)
# x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByBillingAccountReservationDetails.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 armcostmanagement_test
import (
"context"
"log"
"time"
"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/costmanagement/armcostmanagement/v3"
)
// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByBillingAccountReservationDetails.json
func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccountReservationDetails() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcostmanagement.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{
Identity: &armcostmanagement.SystemAssignedServiceIdentity{
Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
},
Location: to.Ptr("centralus"),
Properties: &armcostmanagement.ExportProperties{
Format: to.Ptr(armcostmanagement.FormatTypeCSV),
CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
Definition: &armcostmanagement.ExportDefinition{
Type: to.Ptr(armcostmanagement.ExportTypeReservationDetails),
DataSet: &armcostmanagement.ExportDataset{
Configuration: &armcostmanagement.ExportDatasetConfiguration{
DataVersion: to.Ptr("2023-03-01"),
},
Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
},
Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
},
DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
Destination: &armcostmanagement.ExportDeliveryDestination{
Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob),
Container: to.Ptr("exports"),
ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
RootFolderPath: to.Ptr("ad-hoc"),
},
},
ExportDescription: to.Ptr("This is a test export."),
PartitionData: to.Ptr(true),
Schedule: &armcostmanagement.ExportSchedule{
Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t }()),
To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); return t }()),
},
Status: to.Ptr(armcostmanagement.StatusTypeActive),
},
},
}, 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 = armcostmanagement.ExportsClientCreateOrUpdateResponse{
// Export: armcostmanagement.Export{
// Name: to.Ptr("TestExport"),
// Type: to.Ptr("Microsoft.CostManagement/exports"),
// ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"),
// Identity: &armcostmanagement.SystemAssignedServiceIdentity{
// Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// Location: to.Ptr("centralus"),
// Properties: &armcostmanagement.ExportProperties{
// Format: to.Ptr(armcostmanagement.FormatTypeCSV),
// CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
// DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
// Definition: &armcostmanagement.ExportDefinition{
// Type: to.Ptr(armcostmanagement.ExportTypeReservationDetails),
// DataSet: &armcostmanagement.ExportDataset{
// Configuration: &armcostmanagement.ExportDatasetConfiguration{
// Columns: []*string{
// },
// DataVersion: to.Ptr("2023-03-01"),
// Filters: []*armcostmanagement.FilterItems{
// },
// },
// Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
// },
// Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
// },
// DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
// Destination: &armcostmanagement.ExportDeliveryDestination{
// Container: to.Ptr("exports"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
// RootFolderPath: to.Ptr("ad-hoc"),
// },
// },
// ExportDescription: to.Ptr("This is a test export."),
// NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T23:00:00Z"); return t}()),
// PartitionData: to.Ptr(true),
// Schedule: &armcostmanagement.ExportSchedule{
// Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
// RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
// From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t}()),
// To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); return t}()),
// },
// Status: to.Ptr(armcostmanagement.StatusTypeActive),
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CostManagementClient } = require("@azure/arm-costmanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
*
* @summary the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
* x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByBillingAccountReservationDetails.json
*/
async function exportCreateOrUpdateByBillingAccountReservationDetails() {
const credential = new DefaultAzureCredential();
const client = new CostManagementClient(credential);
const result = await client.exports.createOrUpdate(
"providers/Microsoft.Billing/billingAccounts/123456",
"TestExport",
{
identity: { type: "SystemAssigned" },
location: "centralus",
format: "Csv",
compressionMode: "gzip",
dataOverwriteBehavior: "OverwritePreviousReport",
definition: {
type: "ReservationDetails",
dataSet: { configuration: { dataVersion: "2023-03-01" }, granularity: "Daily" },
timeframe: "MonthToDate",
},
deliveryInfo: {
destination: {
type: "AzureBlob",
container: "exports",
resourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
rootFolderPath: "ad-hoc",
},
},
exportDescription: "This is a test export.",
partitionData: true,
schedule: {
recurrence: "Daily",
recurrencePeriod: {
from: new Date("2023-06-01T00:00:00Z"),
to: new Date("2023-06-30T00:00:00Z"),
},
status: "Active",
},
},
);
console.log(result);
}
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
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ReservationDetails",
"dataSet": {
"configuration": {
"columns": [],
"dataVersion": "2023-03-01",
"filters": []
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2023-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2023-06-01T00:00:00Z",
"to": "2023-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ReservationDetails",
"dataSet": {
"configuration": {
"columns": [],
"dataVersion": "2023-03-01",
"filters": []
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2023-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2023-06-01T00:00:00Z",
"to": "2023-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
ExportCreateOrUpdateByBillingAccountReservationRecommendation
Solicitud de ejemplo
PUT https://management.azure.com/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport?api-version=2025-03-01
{
"identity": {
"type": "SystemAssigned"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ReservationRecommendations",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01",
"filters": [
{
"name": "ReservationScope",
"value": "Single"
},
{
"name": "ResourceType",
"value": "VirtualMachines"
},
{
"name": "LookBackPeriod",
"value": "Last7Days"
}
]
}
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"type": "AzureBlob",
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2023-06-01T00:00:00Z",
"to": "2023-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.costmanagement import CostManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-costmanagement
# USAGE
python export_create_or_update_by_billing_account_reservation_recommendation.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 = CostManagementClient(
credential=DefaultAzureCredential(),
)
response = client.exports.create_or_update(
scope="providers/Microsoft.Billing/billingAccounts/123456",
export_name="TestExport",
parameters={
"identity": {"type": "SystemAssigned"},
"location": "centralus",
"properties": {
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01",
"filters": [
{"name": "ReservationScope", "value": "Single"},
{"name": "ResourceType", "value": "VirtualMachines"},
{"name": "LookBackPeriod", "value": "Last7Days"},
],
}
},
"timeframe": "MonthToDate",
"type": "ReservationRecommendations",
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc",
"type": "AzureBlob",
}
},
"exportDescription": "This is a test export.",
"format": "Csv",
"partitionData": True,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {"from": "2023-06-01T00:00:00Z", "to": "2023-06-30T00:00:00Z"},
"status": "Active",
},
},
},
)
print(response)
# x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByBillingAccountReservationRecommendation.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 armcostmanagement_test
import (
"context"
"log"
"time"
"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/costmanagement/armcostmanagement/v3"
)
// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByBillingAccountReservationRecommendation.json
func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccountReservationRecommendation() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcostmanagement.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{
Identity: &armcostmanagement.SystemAssignedServiceIdentity{
Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
},
Location: to.Ptr("centralus"),
Properties: &armcostmanagement.ExportProperties{
Format: to.Ptr(armcostmanagement.FormatTypeCSV),
CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
Definition: &armcostmanagement.ExportDefinition{
Type: to.Ptr(armcostmanagement.ExportTypeReservationRecommendations),
DataSet: &armcostmanagement.ExportDataset{
Configuration: &armcostmanagement.ExportDatasetConfiguration{
DataVersion: to.Ptr("2023-05-01"),
Filters: []*armcostmanagement.FilterItems{
{
Name: to.Ptr(armcostmanagement.FilterItemNamesReservationScope),
Value: to.Ptr("Single"),
},
{
Name: to.Ptr(armcostmanagement.FilterItemNamesResourceType),
Value: to.Ptr("VirtualMachines"),
},
{
Name: to.Ptr(armcostmanagement.FilterItemNamesLookBackPeriod),
Value: to.Ptr("Last7Days"),
},
},
},
},
Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
},
DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
Destination: &armcostmanagement.ExportDeliveryDestination{
Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob),
Container: to.Ptr("exports"),
ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
RootFolderPath: to.Ptr("ad-hoc"),
},
},
ExportDescription: to.Ptr("This is a test export."),
PartitionData: to.Ptr(true),
Schedule: &armcostmanagement.ExportSchedule{
Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t }()),
To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); return t }()),
},
Status: to.Ptr(armcostmanagement.StatusTypeActive),
},
},
}, 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 = armcostmanagement.ExportsClientCreateOrUpdateResponse{
// Export: armcostmanagement.Export{
// Name: to.Ptr("TestExport"),
// Type: to.Ptr("Microsoft.CostManagement/exports"),
// ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"),
// Identity: &armcostmanagement.SystemAssignedServiceIdentity{
// Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// Location: to.Ptr("centralus"),
// Properties: &armcostmanagement.ExportProperties{
// Format: to.Ptr(armcostmanagement.FormatTypeCSV),
// CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
// DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
// Definition: &armcostmanagement.ExportDefinition{
// Type: to.Ptr(armcostmanagement.ExportTypeReservationRecommendations),
// DataSet: &armcostmanagement.ExportDataset{
// Configuration: &armcostmanagement.ExportDatasetConfiguration{
// Columns: []*string{
// },
// DataVersion: to.Ptr("2023-05-01"),
// Filters: []*armcostmanagement.FilterItems{
// {
// Name: to.Ptr(armcostmanagement.FilterItemNamesReservationScope),
// Value: to.Ptr("Single"),
// },
// {
// Name: to.Ptr(armcostmanagement.FilterItemNamesResourceType),
// Value: to.Ptr("VirtualMachines"),
// },
// {
// Name: to.Ptr(armcostmanagement.FilterItemNamesLookBackPeriod),
// Value: to.Ptr("Last7Days"),
// },
// },
// },
// },
// Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
// },
// DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
// Destination: &armcostmanagement.ExportDeliveryDestination{
// Container: to.Ptr("exports"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
// RootFolderPath: to.Ptr("ad-hoc"),
// },
// },
// ExportDescription: to.Ptr("This is a test export."),
// NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T23:00:00Z"); return t}()),
// PartitionData: to.Ptr(true),
// Schedule: &armcostmanagement.ExportSchedule{
// Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
// RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
// From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t}()),
// To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); return t}()),
// },
// Status: to.Ptr(armcostmanagement.StatusTypeActive),
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CostManagementClient } = require("@azure/arm-costmanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
*
* @summary the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
* x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByBillingAccountReservationRecommendation.json
*/
async function exportCreateOrUpdateByBillingAccountReservationRecommendation() {
const credential = new DefaultAzureCredential();
const client = new CostManagementClient(credential);
const result = await client.exports.createOrUpdate(
"providers/Microsoft.Billing/billingAccounts/123456",
"TestExport",
{
identity: { type: "SystemAssigned" },
location: "centralus",
format: "Csv",
compressionMode: "gzip",
dataOverwriteBehavior: "OverwritePreviousReport",
definition: {
type: "ReservationRecommendations",
dataSet: {
configuration: {
dataVersion: "2023-05-01",
filters: [
{ name: "ReservationScope", value: "Single" },
{ name: "ResourceType", value: "VirtualMachines" },
{ name: "LookBackPeriod", value: "Last7Days" },
],
},
},
timeframe: "MonthToDate",
},
deliveryInfo: {
destination: {
type: "AzureBlob",
container: "exports",
resourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
rootFolderPath: "ad-hoc",
},
},
exportDescription: "This is a test export.",
partitionData: true,
schedule: {
recurrence: "Daily",
recurrencePeriod: {
from: new Date("2023-06-01T00:00:00Z"),
to: new Date("2023-06-30T00:00:00Z"),
},
status: "Active",
},
},
);
console.log(result);
}
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
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ReservationRecommendations",
"dataSet": {
"configuration": {
"columns": [],
"dataVersion": "2023-05-01",
"filters": [
{
"name": "ReservationScope",
"value": "Single"
},
{
"name": "ResourceType",
"value": "VirtualMachines"
},
{
"name": "LookBackPeriod",
"value": "Last7Days"
}
]
},
"granularity": null
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2023-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2023-06-01T00:00:00Z",
"to": "2023-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ReservationRecommendations",
"dataSet": {
"configuration": {
"columns": [],
"dataVersion": "2023-05-01",
"filters": [
{
"name": "ReservationScope",
"value": "Single"
},
{
"name": "ResourceType",
"value": "VirtualMachines"
},
{
"name": "LookBackPeriod",
"value": "Last7Days"
}
]
},
"granularity": null
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2023-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2023-06-01T00:00:00Z",
"to": "2023-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
ExportCreateOrUpdateByDepartment
Solicitud de ejemplo
PUT https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/TestExport?api-version=2025-03-01
{
"identity": {
"type": "SystemAssigned"
},
"location": "centralus",
"properties": {
"format": "Parquet",
"compressionMode": "snappy",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"type": "AzureBlob",
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.costmanagement import CostManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-costmanagement
# USAGE
python export_create_or_update_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 = CostManagementClient(
credential=DefaultAzureCredential(),
)
response = client.exports.create_or_update(
scope="providers/Microsoft.Billing/billingAccounts/12/departments/1234",
export_name="TestExport",
parameters={
"identity": {"type": "SystemAssigned"},
"location": "centralus",
"properties": {
"compressionMode": "snappy",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"dataSet": {"configuration": {"dataVersion": "2023-05-01"}, "granularity": "Daily"},
"timeframe": "MonthToDate",
"type": "ActualCost",
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc",
"type": "AzureBlob",
}
},
"exportDescription": "This is a test export.",
"format": "Parquet",
"partitionData": True,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {"from": "2020-06-01T00:00:00Z", "to": "2020-06-30T00:00:00Z"},
"status": "Active",
},
},
},
)
print(response)
# x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByDepartment.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 armcostmanagement_test
import (
"context"
"log"
"time"
"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/costmanagement/armcostmanagement/v3"
)
// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByDepartment.json
func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByDepartment() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcostmanagement.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/12/departments/1234", "TestExport", armcostmanagement.Export{
Identity: &armcostmanagement.SystemAssignedServiceIdentity{
Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
},
Location: to.Ptr("centralus"),
Properties: &armcostmanagement.ExportProperties{
Format: to.Ptr(armcostmanagement.FormatTypeParquet),
CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeSnappy),
DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
Definition: &armcostmanagement.ExportDefinition{
Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
DataSet: &armcostmanagement.ExportDataset{
Configuration: &armcostmanagement.ExportDatasetConfiguration{
DataVersion: to.Ptr("2023-05-01"),
},
Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
},
Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
},
DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
Destination: &armcostmanagement.ExportDeliveryDestination{
Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob),
Container: to.Ptr("exports"),
ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
RootFolderPath: to.Ptr("ad-hoc"),
},
},
ExportDescription: to.Ptr("This is a test export."),
PartitionData: to.Ptr(true),
Schedule: &armcostmanagement.ExportSchedule{
Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()),
To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t }()),
},
Status: to.Ptr(armcostmanagement.StatusTypeActive),
},
},
}, 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 = armcostmanagement.ExportsClientCreateOrUpdateResponse{
// Export: armcostmanagement.Export{
// Name: to.Ptr("TestExport"),
// Type: to.Ptr("Microsoft.CostManagement/exports"),
// ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/TestExport"),
// Identity: &armcostmanagement.SystemAssignedServiceIdentity{
// Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// Location: to.Ptr("centralus"),
// Properties: &armcostmanagement.ExportProperties{
// Format: to.Ptr(armcostmanagement.FormatTypeParquet),
// CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeSnappy),
// DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
// Definition: &armcostmanagement.ExportDefinition{
// Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
// DataSet: &armcostmanagement.ExportDataset{
// Configuration: &armcostmanagement.ExportDatasetConfiguration{
// DataVersion: to.Ptr("2023-05-01"),
// },
// Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
// },
// Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
// },
// DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
// Destination: &armcostmanagement.ExportDeliveryDestination{
// Container: to.Ptr("exports"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
// RootFolderPath: to.Ptr("ad-hoc"),
// },
// },
// ExportDescription: to.Ptr("This is a test export."),
// NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T23:00:00Z"); return t}()),
// PartitionData: to.Ptr(true),
// Schedule: &armcostmanagement.ExportSchedule{
// Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
// RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
// From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()),
// To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()),
// },
// Status: to.Ptr(armcostmanagement.StatusTypeActive),
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CostManagementClient } = require("@azure/arm-costmanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
*
* @summary the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
* x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByDepartment.json
*/
async function exportCreateOrUpdateByDepartment() {
const credential = new DefaultAzureCredential();
const client = new CostManagementClient(credential);
const result = await client.exports.createOrUpdate(
"providers/Microsoft.Billing/billingAccounts/12/departments/1234",
"TestExport",
{
identity: { type: "SystemAssigned" },
location: "centralus",
format: "Parquet",
compressionMode: "snappy",
dataOverwriteBehavior: "OverwritePreviousReport",
definition: {
type: "ActualCost",
dataSet: { configuration: { dataVersion: "2023-05-01" }, granularity: "Daily" },
timeframe: "MonthToDate",
},
deliveryInfo: {
destination: {
type: "AzureBlob",
container: "exports",
resourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
rootFolderPath: "ad-hoc",
},
},
exportDescription: "This is a test export.",
partitionData: true,
schedule: {
recurrence: "Daily",
recurrencePeriod: {
from: new Date("2020-06-01T00:00:00Z"),
to: new Date("2020-06-30T00:00:00Z"),
},
status: "Active",
},
},
);
console.log(result);
}
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
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Parquet",
"compressionMode": "snappy",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2020-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Parquet",
"compressionMode": "snappy",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2020-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
ExportCreateOrUpdateByEnrollmentAccount
Solicitud de ejemplo
PUT https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/TestExport?api-version=2025-03-01
{
"identity": {
"type": "SystemAssigned"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"type": "AzureBlob",
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.costmanagement import CostManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-costmanagement
# USAGE
python export_create_or_update_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 = CostManagementClient(
credential=DefaultAzureCredential(),
)
response = client.exports.create_or_update(
scope="providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456",
export_name="TestExport",
parameters={
"identity": {"type": "SystemAssigned"},
"location": "centralus",
"properties": {
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"dataSet": {"configuration": {"dataVersion": "2023-05-01"}, "granularity": "Daily"},
"timeframe": "MonthToDate",
"type": "ActualCost",
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc",
"type": "AzureBlob",
}
},
"exportDescription": "This is a test export.",
"format": "Csv",
"partitionData": True,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {"from": "2020-06-01T00:00:00Z", "to": "2020-06-30T00:00:00Z"},
"status": "Active",
},
},
},
)
print(response)
# x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByEnrollmentAccount.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 armcostmanagement_test
import (
"context"
"log"
"time"
"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/costmanagement/armcostmanagement/v3"
)
// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByEnrollmentAccount.json
func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByEnrollmentAccount() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcostmanagement.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", "TestExport", armcostmanagement.Export{
Identity: &armcostmanagement.SystemAssignedServiceIdentity{
Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
},
Location: to.Ptr("centralus"),
Properties: &armcostmanagement.ExportProperties{
Format: to.Ptr(armcostmanagement.FormatTypeCSV),
CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
Definition: &armcostmanagement.ExportDefinition{
Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
DataSet: &armcostmanagement.ExportDataset{
Configuration: &armcostmanagement.ExportDatasetConfiguration{
DataVersion: to.Ptr("2023-05-01"),
},
Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
},
Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
},
DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
Destination: &armcostmanagement.ExportDeliveryDestination{
Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob),
Container: to.Ptr("exports"),
ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
RootFolderPath: to.Ptr("ad-hoc"),
},
},
ExportDescription: to.Ptr("This is a test export."),
PartitionData: to.Ptr(true),
Schedule: &armcostmanagement.ExportSchedule{
Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()),
To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t }()),
},
Status: to.Ptr(armcostmanagement.StatusTypeActive),
},
},
}, 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 = armcostmanagement.ExportsClientCreateOrUpdateResponse{
// Export: armcostmanagement.Export{
// Name: to.Ptr("TestExport"),
// Type: to.Ptr("Microsoft.CostManagement/exports"),
// ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/TestExport"),
// Identity: &armcostmanagement.SystemAssignedServiceIdentity{
// Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// Location: to.Ptr("centralus"),
// Properties: &armcostmanagement.ExportProperties{
// Format: to.Ptr(armcostmanagement.FormatTypeCSV),
// CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
// DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
// Definition: &armcostmanagement.ExportDefinition{
// Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
// DataSet: &armcostmanagement.ExportDataset{
// Configuration: &armcostmanagement.ExportDatasetConfiguration{
// DataVersion: to.Ptr("2023-05-01"),
// },
// Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
// },
// Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
// },
// DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
// Destination: &armcostmanagement.ExportDeliveryDestination{
// Container: to.Ptr("exports"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
// RootFolderPath: to.Ptr("ad-hoc"),
// },
// },
// ExportDescription: to.Ptr("This is a test export."),
// NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T23:00:00Z"); return t}()),
// PartitionData: to.Ptr(true),
// Schedule: &armcostmanagement.ExportSchedule{
// Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
// RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
// From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()),
// To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()),
// },
// Status: to.Ptr(armcostmanagement.StatusTypeActive),
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CostManagementClient } = require("@azure/arm-costmanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
*
* @summary the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
* x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByEnrollmentAccount.json
*/
async function exportCreateOrUpdateByEnrollmentAccount() {
const credential = new DefaultAzureCredential();
const client = new CostManagementClient(credential);
const result = await client.exports.createOrUpdate(
"providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456",
"TestExport",
{
identity: { type: "SystemAssigned" },
location: "centralus",
format: "Csv",
compressionMode: "gzip",
dataOverwriteBehavior: "OverwritePreviousReport",
definition: {
type: "ActualCost",
dataSet: { configuration: { dataVersion: "2023-05-01" }, granularity: "Daily" },
timeframe: "MonthToDate",
},
deliveryInfo: {
destination: {
type: "AzureBlob",
container: "exports",
resourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
rootFolderPath: "ad-hoc",
},
},
exportDescription: "This is a test export.",
partitionData: true,
schedule: {
recurrence: "Daily",
recurrencePeriod: {
from: new Date("2020-06-01T00:00:00Z"),
to: new Date("2020-06-30T00:00:00Z"),
},
status: "Active",
},
},
);
console.log(result);
}
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
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2020-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2020-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
ExportCreateOrUpdateByManagementGroup
Solicitud de ejemplo
PUT https://management.azure.com/providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport?api-version=2025-03-01
{
"identity": {
"type": "SystemAssigned"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"type": "AzureBlob",
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.costmanagement import CostManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-costmanagement
# USAGE
python export_create_or_update_by_management_group.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = CostManagementClient(
credential=DefaultAzureCredential(),
)
response = client.exports.create_or_update(
scope="providers/Microsoft.Management/managementGroups/TestMG",
export_name="TestExport",
parameters={
"identity": {"type": "SystemAssigned"},
"location": "centralus",
"properties": {
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"dataSet": {"configuration": {"dataVersion": "2023-05-01"}, "granularity": "Daily"},
"timeframe": "MonthToDate",
"type": "ActualCost",
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc",
"type": "AzureBlob",
}
},
"exportDescription": "This is a test export.",
"format": "Csv",
"partitionData": True,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {"from": "2020-06-01T00:00:00Z", "to": "2020-06-30T00:00:00Z"},
"status": "Active",
},
},
},
)
print(response)
# x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByManagementGroup.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 armcostmanagement_test
import (
"context"
"log"
"time"
"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/costmanagement/armcostmanagement/v3"
)
// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByManagementGroup.json
func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByManagementGroup() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcostmanagement.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Management/managementGroups/TestMG", "TestExport", armcostmanagement.Export{
Identity: &armcostmanagement.SystemAssignedServiceIdentity{
Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
},
Location: to.Ptr("centralus"),
Properties: &armcostmanagement.ExportProperties{
Format: to.Ptr(armcostmanagement.FormatTypeCSV),
CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
Definition: &armcostmanagement.ExportDefinition{
Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
DataSet: &armcostmanagement.ExportDataset{
Configuration: &armcostmanagement.ExportDatasetConfiguration{
DataVersion: to.Ptr("2023-05-01"),
},
Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
},
Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
},
DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
Destination: &armcostmanagement.ExportDeliveryDestination{
Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob),
Container: to.Ptr("exports"),
ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
RootFolderPath: to.Ptr("ad-hoc"),
},
},
ExportDescription: to.Ptr("This is a test export."),
PartitionData: to.Ptr(true),
Schedule: &armcostmanagement.ExportSchedule{
Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()),
To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t }()),
},
Status: to.Ptr(armcostmanagement.StatusTypeActive),
},
},
}, 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 = armcostmanagement.ExportsClientCreateOrUpdateResponse{
// Export: armcostmanagement.Export{
// Name: to.Ptr("TestExport"),
// Type: to.Ptr("Microsoft.CostManagement/exports"),
// ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")),
// ID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport"),
// Identity: &armcostmanagement.SystemAssignedServiceIdentity{
// Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// Location: to.Ptr("centralus"),
// Properties: &armcostmanagement.ExportProperties{
// Format: to.Ptr(armcostmanagement.FormatTypeCSV),
// CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
// DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
// Definition: &armcostmanagement.ExportDefinition{
// Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
// DataSet: &armcostmanagement.ExportDataset{
// Configuration: &armcostmanagement.ExportDatasetConfiguration{
// DataVersion: to.Ptr("2023-05-01"),
// },
// Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
// },
// Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
// },
// DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
// Destination: &armcostmanagement.ExportDeliveryDestination{
// Container: to.Ptr("exports"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
// RootFolderPath: to.Ptr("ad-hoc"),
// },
// },
// ExportDescription: to.Ptr("This is a test export."),
// NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T23:00:00Z"); return t}()),
// PartitionData: to.Ptr(true),
// Schedule: &armcostmanagement.ExportSchedule{
// Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
// RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
// From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()),
// To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()),
// },
// Status: to.Ptr(armcostmanagement.StatusTypeActive),
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CostManagementClient } = require("@azure/arm-costmanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
*
* @summary the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
* x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByManagementGroup.json
*/
async function exportCreateOrUpdateByManagementGroup() {
const credential = new DefaultAzureCredential();
const client = new CostManagementClient(credential);
const result = await client.exports.createOrUpdate(
"providers/Microsoft.Management/managementGroups/TestMG",
"TestExport",
{
identity: { type: "SystemAssigned" },
location: "centralus",
format: "Csv",
compressionMode: "gzip",
dataOverwriteBehavior: "OverwritePreviousReport",
definition: {
type: "ActualCost",
dataSet: { configuration: { dataVersion: "2023-05-01" }, granularity: "Daily" },
timeframe: "MonthToDate",
},
deliveryInfo: {
destination: {
type: "AzureBlob",
container: "exports",
resourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
rootFolderPath: "ad-hoc",
},
},
exportDescription: "This is a test export.",
partitionData: true,
schedule: {
recurrence: "Daily",
recurrencePeriod: {
from: new Date("2020-06-01T00:00:00Z"),
to: new Date("2020-06-30T00:00:00Z"),
},
status: "Active",
},
},
);
console.log(result);
}
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
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2020-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2020-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
ExportCreateOrUpdateByResourceGroup
Solicitud de ejemplo
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/TestExport?api-version=2025-03-01
{
"identity": {
"type": "SystemAssigned"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"type": "AzureBlob",
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.costmanagement import CostManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-costmanagement
# USAGE
python export_create_or_update_by_resource_group.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = CostManagementClient(
credential=DefaultAzureCredential(),
)
response = client.exports.create_or_update(
scope="subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG",
export_name="TestExport",
parameters={
"identity": {"type": "SystemAssigned"},
"location": "centralus",
"properties": {
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"dataSet": {"configuration": {"dataVersion": "2023-05-01"}, "granularity": "Daily"},
"timeframe": "MonthToDate",
"type": "ActualCost",
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc",
"type": "AzureBlob",
}
},
"exportDescription": "This is a test export.",
"format": "Csv",
"partitionData": True,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {"from": "2020-06-01T00:00:00Z", "to": "2020-06-30T00:00:00Z"},
"status": "Active",
},
},
},
)
print(response)
# x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByResourceGroup.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 armcostmanagement_test
import (
"context"
"log"
"time"
"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/costmanagement/armcostmanagement/v3"
)
// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByResourceGroup.json
func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByResourceGroup() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcostmanagement.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "TestExport", armcostmanagement.Export{
Identity: &armcostmanagement.SystemAssignedServiceIdentity{
Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
},
Location: to.Ptr("centralus"),
Properties: &armcostmanagement.ExportProperties{
Format: to.Ptr(armcostmanagement.FormatTypeCSV),
CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
Definition: &armcostmanagement.ExportDefinition{
Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
DataSet: &armcostmanagement.ExportDataset{
Configuration: &armcostmanagement.ExportDatasetConfiguration{
DataVersion: to.Ptr("2023-05-01"),
},
Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
},
Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
},
DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
Destination: &armcostmanagement.ExportDeliveryDestination{
Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob),
Container: to.Ptr("exports"),
ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
RootFolderPath: to.Ptr("ad-hoc"),
},
},
ExportDescription: to.Ptr("This is a test export."),
PartitionData: to.Ptr(true),
Schedule: &armcostmanagement.ExportSchedule{
Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()),
To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t }()),
},
Status: to.Ptr(armcostmanagement.StatusTypeActive),
},
},
}, 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 = armcostmanagement.ExportsClientCreateOrUpdateResponse{
// Export: armcostmanagement.Export{
// Name: to.Ptr("TestExport"),
// Type: to.Ptr("Microsoft.CostManagement/exports"),
// ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/TestExport"),
// Identity: &armcostmanagement.SystemAssignedServiceIdentity{
// Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// Location: to.Ptr("centralus"),
// Properties: &armcostmanagement.ExportProperties{
// Format: to.Ptr(armcostmanagement.FormatTypeCSV),
// CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
// DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
// Definition: &armcostmanagement.ExportDefinition{
// Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
// DataSet: &armcostmanagement.ExportDataset{
// Configuration: &armcostmanagement.ExportDatasetConfiguration{
// DataVersion: to.Ptr("2023-05-01"),
// },
// Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
// },
// Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
// },
// DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
// Destination: &armcostmanagement.ExportDeliveryDestination{
// Container: to.Ptr("exports"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
// RootFolderPath: to.Ptr("ad-hoc"),
// },
// },
// ExportDescription: to.Ptr("This is a test export."),
// NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T23:00:00Z"); return t}()),
// PartitionData: to.Ptr(true),
// Schedule: &armcostmanagement.ExportSchedule{
// Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
// RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
// From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()),
// To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()),
// },
// Status: to.Ptr(armcostmanagement.StatusTypeActive),
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CostManagementClient } = require("@azure/arm-costmanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
*
* @summary the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
* x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByResourceGroup.json
*/
async function exportCreateOrUpdateByResourceGroup() {
const credential = new DefaultAzureCredential();
const client = new CostManagementClient(credential);
const result = await client.exports.createOrUpdate(
"subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG",
"TestExport",
{
identity: { type: "SystemAssigned" },
location: "centralus",
format: "Csv",
compressionMode: "gzip",
dataOverwriteBehavior: "OverwritePreviousReport",
definition: {
type: "ActualCost",
dataSet: { configuration: { dataVersion: "2023-05-01" }, granularity: "Daily" },
timeframe: "MonthToDate",
},
deliveryInfo: {
destination: {
type: "AzureBlob",
container: "exports",
resourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
rootFolderPath: "ad-hoc",
},
},
exportDescription: "This is a test export.",
partitionData: true,
schedule: {
recurrence: "Daily",
recurrencePeriod: {
from: new Date("2020-06-01T00:00:00Z"),
to: new Date("2020-06-30T00:00:00Z"),
},
status: "Active",
},
},
);
console.log(result);
}
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
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2020-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2020-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
ExportCreateOrUpdateBySubscription
Solicitud de ejemplo
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/TestExport?api-version=2025-03-01
{
"identity": {
"type": "SystemAssigned"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"type": "AzureBlob",
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.costmanagement import CostManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-costmanagement
# USAGE
python export_create_or_update_by_subscription.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 = CostManagementClient(
credential=DefaultAzureCredential(),
)
response = client.exports.create_or_update(
scope="subscriptions/00000000-0000-0000-0000-000000000000",
export_name="TestExport",
parameters={
"identity": {"type": "SystemAssigned"},
"location": "centralus",
"properties": {
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"dataSet": {"configuration": {"dataVersion": "2023-05-01"}, "granularity": "Daily"},
"timeframe": "MonthToDate",
"type": "ActualCost",
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc",
"type": "AzureBlob",
}
},
"exportDescription": "This is a test export.",
"format": "Csv",
"partitionData": True,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {"from": "2020-06-01T00:00:00Z", "to": "2020-06-30T00:00:00Z"},
"status": "Active",
},
},
},
)
print(response)
# x-ms-original-file: 2025-03-01/ExportCreateOrUpdateBySubscription.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 armcostmanagement_test
import (
"context"
"log"
"time"
"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/costmanagement/armcostmanagement/v3"
)
// Generated from example definition: 2025-03-01/ExportCreateOrUpdateBySubscription.json
func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateBySubscription() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcostmanagement.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestExport", armcostmanagement.Export{
Identity: &armcostmanagement.SystemAssignedServiceIdentity{
Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
},
Location: to.Ptr("centralus"),
Properties: &armcostmanagement.ExportProperties{
Format: to.Ptr(armcostmanagement.FormatTypeCSV),
CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
Definition: &armcostmanagement.ExportDefinition{
Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
DataSet: &armcostmanagement.ExportDataset{
Configuration: &armcostmanagement.ExportDatasetConfiguration{
DataVersion: to.Ptr("2023-05-01"),
},
Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
},
Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
},
DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
Destination: &armcostmanagement.ExportDeliveryDestination{
Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob),
Container: to.Ptr("exports"),
ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
RootFolderPath: to.Ptr("ad-hoc"),
},
},
ExportDescription: to.Ptr("This is a test export."),
PartitionData: to.Ptr(true),
Schedule: &armcostmanagement.ExportSchedule{
Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()),
To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t }()),
},
Status: to.Ptr(armcostmanagement.StatusTypeActive),
},
},
}, 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 = armcostmanagement.ExportsClientCreateOrUpdateResponse{
// Export: armcostmanagement.Export{
// Name: to.Ptr("TestExport"),
// Type: to.Ptr("Microsoft.CostManagement/exports"),
// ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/TestExport"),
// Identity: &armcostmanagement.SystemAssignedServiceIdentity{
// Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// Location: to.Ptr("centralus"),
// Properties: &armcostmanagement.ExportProperties{
// Format: to.Ptr(armcostmanagement.FormatTypeCSV),
// CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
// DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
// Definition: &armcostmanagement.ExportDefinition{
// Type: to.Ptr(armcostmanagement.ExportTypeActualCost),
// DataSet: &armcostmanagement.ExportDataset{
// Configuration: &armcostmanagement.ExportDatasetConfiguration{
// DataVersion: to.Ptr("2023-05-01"),
// },
// Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily),
// },
// Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
// },
// DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
// Destination: &armcostmanagement.ExportDeliveryDestination{
// Container: to.Ptr("exports"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
// RootFolderPath: to.Ptr("ad-hoc"),
// },
// },
// ExportDescription: to.Ptr("This is a test export."),
// NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T23:00:00Z"); return t}()),
// PartitionData: to.Ptr(true),
// Schedule: &armcostmanagement.ExportSchedule{
// Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
// RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
// From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()),
// To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()),
// },
// Status: to.Ptr(armcostmanagement.StatusTypeActive),
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CostManagementClient } = require("@azure/arm-costmanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
*
* @summary the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
* x-ms-original-file: 2025-03-01/ExportCreateOrUpdateBySubscription.json
*/
async function exportCreateOrUpdateBySubscription() {
const credential = new DefaultAzureCredential();
const client = new CostManagementClient(credential);
const result = await client.exports.createOrUpdate(
"subscriptions/00000000-0000-0000-0000-000000000000",
"TestExport",
{
identity: { type: "SystemAssigned" },
location: "centralus",
format: "Csv",
compressionMode: "gzip",
dataOverwriteBehavior: "OverwritePreviousReport",
definition: {
type: "ActualCost",
dataSet: { configuration: { dataVersion: "2023-05-01" }, granularity: "Daily" },
timeframe: "MonthToDate",
},
deliveryInfo: {
destination: {
type: "AzureBlob",
container: "exports",
resourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
rootFolderPath: "ad-hoc",
},
},
exportDescription: "This is a test export.",
partitionData: true,
schedule: {
recurrence: "Daily",
recurrencePeriod: {
from: new Date("2020-06-01T00:00:00Z"),
to: new Date("2020-06-30T00:00:00Z"),
},
status: "Active",
},
},
);
console.log(result);
}
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
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2020-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ActualCost",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
},
"granularity": "Daily"
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2020-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2020-06-01T00:00:00Z",
"to": "2020-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
ExportCreateOrUpdateExportCreateOrUpdateByBillingAccountReservationTransactionsByBillingAccount
Solicitud de ejemplo
PUT https://management.azure.com/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport?api-version=2025-03-01
{
"identity": {
"type": "SystemAssigned"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ReservationTransactions",
"dataSet": {
"configuration": {
"dataVersion": "2023-05-01"
}
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"type": "AzureBlob",
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2023-06-01T00:00:00Z",
"to": "2023-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.costmanagement import CostManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-costmanagement
# USAGE
python export_create_or_update_by_billing_account_reservation_transactions.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 = CostManagementClient(
credential=DefaultAzureCredential(),
)
response = client.exports.create_or_update(
scope="providers/Microsoft.Billing/billingAccounts/123456",
export_name="TestExport",
parameters={
"identity": {"type": "SystemAssigned"},
"location": "centralus",
"properties": {
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"dataSet": {"configuration": {"dataVersion": "2023-05-01"}},
"timeframe": "MonthToDate",
"type": "ReservationTransactions",
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc",
"type": "AzureBlob",
}
},
"exportDescription": "This is a test export.",
"format": "Csv",
"partitionData": True,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {"from": "2023-06-01T00:00:00Z", "to": "2023-06-30T00:00:00Z"},
"status": "Active",
},
},
},
)
print(response)
# x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByBillingAccountReservationTransactions.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 armcostmanagement_test
import (
"context"
"log"
"time"
"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/costmanagement/armcostmanagement/v3"
)
// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByBillingAccountReservationTransactions.json
func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateExportCreateOrUpdateByBillingAccountReservationTransactionsByBillingAccount() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcostmanagement.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{
Identity: &armcostmanagement.SystemAssignedServiceIdentity{
Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
},
Location: to.Ptr("centralus"),
Properties: &armcostmanagement.ExportProperties{
Format: to.Ptr(armcostmanagement.FormatTypeCSV),
CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
Definition: &armcostmanagement.ExportDefinition{
Type: to.Ptr(armcostmanagement.ExportTypeReservationTransactions),
DataSet: &armcostmanagement.ExportDataset{
Configuration: &armcostmanagement.ExportDatasetConfiguration{
DataVersion: to.Ptr("2023-05-01"),
},
},
Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
},
DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
Destination: &armcostmanagement.ExportDeliveryDestination{
Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob),
Container: to.Ptr("exports"),
ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
RootFolderPath: to.Ptr("ad-hoc"),
},
},
ExportDescription: to.Ptr("This is a test export."),
PartitionData: to.Ptr(true),
Schedule: &armcostmanagement.ExportSchedule{
Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t }()),
To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); return t }()),
},
Status: to.Ptr(armcostmanagement.StatusTypeActive),
},
},
}, 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 = armcostmanagement.ExportsClientCreateOrUpdateResponse{
// Export: armcostmanagement.Export{
// Name: to.Ptr("TestExport"),
// Type: to.Ptr("Microsoft.CostManagement/exports"),
// ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"),
// Identity: &armcostmanagement.SystemAssignedServiceIdentity{
// Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned),
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// Location: to.Ptr("centralus"),
// Properties: &armcostmanagement.ExportProperties{
// Format: to.Ptr(armcostmanagement.FormatTypeCSV),
// CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip),
// DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport),
// Definition: &armcostmanagement.ExportDefinition{
// Type: to.Ptr(armcostmanagement.ExportTypeReservationTransactions),
// DataSet: &armcostmanagement.ExportDataset{
// Configuration: &armcostmanagement.ExportDatasetConfiguration{
// Columns: []*string{
// },
// DataVersion: to.Ptr("2023-05-01"),
// Filters: []*armcostmanagement.FilterItems{
// },
// },
// },
// Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate),
// },
// DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{
// Destination: &armcostmanagement.ExportDeliveryDestination{
// Container: to.Ptr("exports"),
// ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"),
// RootFolderPath: to.Ptr("ad-hoc"),
// },
// },
// ExportDescription: to.Ptr("This is a test export."),
// NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T23:00:00Z"); return t}()),
// PartitionData: to.Ptr(true),
// Schedule: &armcostmanagement.ExportSchedule{
// Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily),
// RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{
// From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t}()),
// To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); return t}()),
// },
// Status: to.Ptr(armcostmanagement.StatusTypeActive),
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { CostManagementClient } = require("@azure/arm-costmanagement");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
*
* @summary the operation to create or update a export. Update operation requires latest eTag to be set in the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
* x-ms-original-file: 2025-03-01/ExportCreateOrUpdateByBillingAccountReservationTransactions.json
*/
async function exportCreateOrUpdateExportCreateOrUpdateByBillingAccountReservationTransactionsByBillingAccount() {
const credential = new DefaultAzureCredential();
const client = new CostManagementClient(credential);
const result = await client.exports.createOrUpdate(
"providers/Microsoft.Billing/billingAccounts/123456",
"TestExport",
{
identity: { type: "SystemAssigned" },
location: "centralus",
format: "Csv",
compressionMode: "gzip",
dataOverwriteBehavior: "OverwritePreviousReport",
definition: {
type: "ReservationTransactions",
dataSet: { configuration: { dataVersion: "2023-05-01" } },
timeframe: "MonthToDate",
},
deliveryInfo: {
destination: {
type: "AzureBlob",
container: "exports",
resourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
rootFolderPath: "ad-hoc",
},
},
exportDescription: "This is a test export.",
partitionData: true,
schedule: {
recurrence: "Daily",
recurrencePeriod: {
from: new Date("2023-06-01T00:00:00Z"),
to: new Date("2023-06-30T00:00:00Z"),
},
status: "Active",
},
},
);
console.log(result);
}
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
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ReservationTransactions",
"dataSet": {
"configuration": {
"columns": [],
"dataVersion": "2023-05-01",
"filters": []
},
"granularity": null
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2023-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2023-06-01T00:00:00Z",
"to": "2023-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
{
"name": "TestExport",
"type": "Microsoft.CostManagement/exports",
"eTag": "\"00000000-0000-0000-0000-000000000000\"",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport",
"identity": {
"type": "SystemAssigned",
"principalId": "00000000-0000-0000-0000-000000000000",
"tenantId": "00000000-0000-0000-0000-000000000000"
},
"location": "centralus",
"properties": {
"format": "Csv",
"compressionMode": "gzip",
"dataOverwriteBehavior": "OverwritePreviousReport",
"definition": {
"type": "ReservationTransactions",
"dataSet": {
"configuration": {
"columns": [],
"dataVersion": "2023-05-01",
"filters": []
},
"granularity": null
},
"timeframe": "MonthToDate"
},
"deliveryInfo": {
"destination": {
"container": "exports",
"resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182",
"rootFolderPath": "ad-hoc"
}
},
"exportDescription": "This is a test export.",
"nextRunTimeEstimate": "2023-06-01T23:00:00Z",
"partitionData": true,
"schedule": {
"recurrence": "Daily",
"recurrencePeriod": {
"from": "2023-06-01T00:00:00Z",
"to": "2023-06-30T00:00:00Z"
},
"status": "Active"
}
}
}
Definiciones
| Nombre |
Description |
|
CommonExportProperties
|
Las propiedades comunes de la exportación.
|
|
CompressionModeType
|
Permitir que los clientes seleccionen comprimir datos para las exportaciones. Esta configuración habilitará el esquema de compresión de archivos de destino en tiempo de ejecución. De forma predeterminada, establezca en Ninguno. Gzip es para csv y snappy para parquet.
|
|
createdByType
|
Tipo de identidad que creó el recurso.
|
|
DataOverwriteBehaviorType
|
Permitir que los clientes seleccionen sobrescribir datos (OverwritePreviousReport) para las exportaciones. Esta configuración habilitará la sobrescritura de datos para el mismo mes en la cuenta de almacenamiento del cliente. De forma predeterminada, establezca en CreateNewReport.
|
|
DestinationType
|
Tipo de destino de entrega de exportación. Actualmente solo se admite "AzureBlob".
|
|
ErrorDetails
|
Detalles del error.
|
|
ErrorResponse
|
La respuesta de error indica que el servicio no puede procesar la solicitud entrante. El motivo se proporciona en el mensaje de error. \n\nAlgunas respuestas a errores: \n\n * 429 TooManyRequests - La solicitud está limitada. Vuelva a intentarlo después de esperar el tiempo especificado en el encabezado "x-ms-ratelimit-microsoft.consumption-retry-after". \n\n * 503 ServiceNo disponible - El servicio está temporalmente no disponible. Vuelva a intentarlo después de esperar el tiempo especificado en el encabezado "Retry-After".
|
|
ExecutionStatus
|
El último estado conocido de la ejecución de exportación.
|
|
ExecutionType
|
Tipo de la ejecución de exportación.
|
|
Export
|
Un recurso de exportación.
|
|
ExportDataset
|
Definición de los datos de la exportación.
|
|
ExportDatasetConfiguration
|
Esto está en ruta de desuso y no se admitirá en el futuro.
|
|
ExportDefinition
|
Definición de una exportación.
|
|
ExportDeliveryDestination
|
Esto representa la ubicación de la cuenta de Blob Storage donde se entregarán las exportaciones de costos. Hay dos maneras de configurar el destino. El enfoque recomendado para la mayoría de los clientes es especificar el resourceId de la cuenta de almacenamiento. Esto requiere un registro único de la suscripción de la cuenta con el proveedor de recursos Microsoft.CostManagementExports para conceder acceso a los servicios de Cost Management al almacenamiento. Al crear una exportación en Azure Portal, este registro se realiza automáticamente, pero es posible que los usuarios de la API necesiten registrar la suscripción explícitamente (para obtener más información, consulte https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services ). Otra manera de configurar el destino solo está disponible para los partners con un plan de Contrato de partners de Microsoft que sean administradores globales de su cuenta de facturación. Estos asociados, en lugar de especificar el resourceId de una cuenta de almacenamiento, pueden especificar el nombre de la cuenta de almacenamiento junto con un token de SAS para la cuenta. Esto permite las exportaciones de costos a una cuenta de almacenamiento en cualquier inquilino. El token de SAS debe crearse para el servicio de blobs con tipos de recursos Service/Container/Object y con permisos de lectura, escritura, eliminación, lista,agregar o crear (para obtener más información, consulte https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/export-cost-data-storage-account-sas-key ).
|
|
ExportDeliveryInfo
|
Información de entrega asociada a una exportación.
|
|
ExportExecutionListResult
|
Resultado de enumerar el historial de ejecución de una exportación.
|
|
ExportRecurrencePeriod
|
Fecha de inicio y finalización de la programación de periodicidad.
|
|
ExportRun
|
Una ejecución de exportación.
|
|
ExportSchedule
|
Programación asociada a la exportación.
|
|
ExportSuspensionContext
|
Propiedades de la ejecución de exportación. Esto no está poblado actualmente.
|
|
ExportTimePeriod
|
Intervalo de fechas para los datos de la exportación. Esto solo debe especificarse con timeFrame establecido en "Custom". El rango de fechas máximo es de 1 mes calendario.
|
|
ExportType
|
Tipo de la exportación. Tenga en cuenta que "Uso" es equivalente a "ActualCost" y es aplicable a las exportaciones que aún no proporcionan datos de cargos o amortización para las reservas de servicio.
|
|
FilterItemNames
|
Nombre del filtro. Actualmente solo se admite para el tipo de definición de exportación de ReservationRecommendations. Los nombres admitidos son ['ReservationScope', 'LookBackPeriod', 'ResourceType']
|
|
FilterItems
|
Contendrá el nombre del filtro y el valor en los que operar. Actualmente solo se admite para el tipo de definición de exportación de ReservationRecommendations.
|
|
FormatType
|
Formato de la exportación que se va a entregar.
|
|
GranularityType
|
Granularidad de las filas de la exportación. Actualmente se admite "Daily" para la mayoría de los casos.
|
|
RecurrenceType
|
Periodicidad de la programación.
|
|
StatusType
|
Estado de la programación de la exportación. Si "Inactivo", se pausa la programación de la exportación. Para habilitar la exportación, establezca el estado como Activo y, a continuación, realice una solicitud PUT.
|
|
SystemAssignedServiceIdentity
|
Identidad de servicio administrada (asignada por el sistema o ninguna)
|
|
SystemAssignedServiceIdentityType
|
Tipo de identidad de servicio administrada (asignada por el sistema o ninguna).
|
|
systemData
|
Metadatos relativos a la creación y última modificación del recurso.
|
|
TimeframeType
|
Período de tiempo para extraer datos para la exportación. Si es personalizado, se debe proporcionar un período de tiempo específico.
|
CommonExportProperties
Objeto
Las propiedades comunes de la exportación.
| Nombre |
Tipo |
Description |
|
compressionMode
|
CompressionModeType
|
Permitir que los clientes seleccionen comprimir datos para las exportaciones. Esta configuración habilitará el esquema de compresión de archivos de destino en tiempo de ejecución. De forma predeterminada, establezca en Ninguno. Gzip es para csv y snappy para parquet.
|
|
dataOverwriteBehavior
|
DataOverwriteBehaviorType
|
Permitir que los clientes seleccionen sobrescribir datos (OverwritePreviousReport) para las exportaciones. Esta configuración habilitará la sobrescritura de datos para el mismo mes en la cuenta de almacenamiento del cliente. De forma predeterminada, establezca en CreateNewReport.
|
|
definition
|
ExportDefinition
|
Tiene la definición de la exportación.
|
|
deliveryInfo
|
ExportDeliveryInfo
|
Tiene información de entrega para la exportación.
|
|
exportDescription
|
string
|
Descripción de exportación establecida por el cliente en el momento de la creación o actualización de la exportación.
|
|
format
|
FormatType
|
Formato de la exportación que se va a entregar.
|
|
nextRunTimeEstimate
|
string
(date-time)
|
Si la exportación tiene una programación activa, proporciona una estimación del siguiente tiempo de ejecución.
|
|
partitionData
|
boolean
|
Si se establece en true, los datos exportados se particionarán por tamaño y se colocarán en un directorio de blobs junto con un archivo de manifiesto.
|
|
runHistory
|
ExportExecutionListResult
|
Si se solicita, tiene el historial de ejecución más reciente para la exportación.
|
|
systemSuspensionContext
|
ExportSuspensionContext
|
Motivo de suspensión de exportación si la exportación está en estado SystemSuspended. Esto no está poblado actualmente.
|
CompressionModeType
Enumeración
Permitir que los clientes seleccionen comprimir datos para las exportaciones. Esta configuración habilitará el esquema de compresión de archivos de destino en tiempo de ejecución. De forma predeterminada, establezca en Ninguno. Gzip es para csv y snappy para parquet.
| Valor |
Description |
|
gzip
|
|
|
snappy
|
|
|
none
|
|
createdByType
Enumeración
Tipo de identidad que creó el recurso.
| Valor |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
DataOverwriteBehaviorType
Enumeración
Permitir que los clientes seleccionen sobrescribir datos (OverwritePreviousReport) para las exportaciones. Esta configuración habilitará la sobrescritura de datos para el mismo mes en la cuenta de almacenamiento del cliente. De forma predeterminada, establezca en CreateNewReport.
| Valor |
Description |
|
OverwritePreviousReport
|
|
|
CreateNewReport
|
|
DestinationType
Enumeración
Tipo de destino de entrega de exportación. Actualmente solo se admite "AzureBlob".
| Valor |
Description |
|
AzureBlob
|
|
ErrorDetails
Objeto
Detalles del error.
| Nombre |
Tipo |
Description |
|
code
|
string
|
Código de error.
|
|
message
|
string
|
Mensaje de error que indica por qué se produjo un error en la operación.
|
ErrorResponse
Objeto
La respuesta de error indica que el servicio no puede procesar la solicitud entrante. El motivo se proporciona en el mensaje de error. \n\nAlgunas respuestas a errores: \n\n * 429 TooManyRequests - La solicitud está limitada. Vuelva a intentarlo después de esperar el tiempo especificado en el encabezado "x-ms-ratelimit-microsoft.consumption-retry-after". \n\n * 503 ServiceNo disponible - El servicio está temporalmente no disponible. Vuelva a intentarlo después de esperar el tiempo especificado en el encabezado "Retry-After".
| Nombre |
Tipo |
Description |
|
error
|
ErrorDetails
|
Detalles del error.
|
ExecutionStatus
Enumeración
El último estado conocido de la ejecución de exportación.
| Valor |
Description |
|
Queued
|
|
|
InProgress
|
|
|
Completed
|
|
|
Failed
|
|
|
Timeout
|
|
|
NewDataNotAvailable
|
|
|
DataNotAvailable
|
|
ExecutionType
Enumeración
Tipo de la ejecución de exportación.
| Valor |
Description |
|
OnDemand
|
|
|
Scheduled
|
|
Export
Objeto
Un recurso de exportación.
| 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
(arm-id)
|
Identificador de recurso completo para el recurso. Por ejemplo, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
identity
|
SystemAssignedServiceIdentity
|
Identidad administrada asociada a Export
|
|
location
|
string
|
Ubicación de la identidad administrada de la exportación. Solo es necesario al usar la identidad administrada.
|
|
name
|
string
|
Nombre del recurso
|
|
properties.compressionMode
|
CompressionModeType
|
Permitir que los clientes seleccionen comprimir datos para las exportaciones. Esta configuración habilitará el esquema de compresión de archivos de destino en tiempo de ejecución. De forma predeterminada, establezca en Ninguno. Gzip es para csv y snappy para parquet.
|
|
properties.dataOverwriteBehavior
|
DataOverwriteBehaviorType
|
Permitir que los clientes seleccionen sobrescribir datos (OverwritePreviousReport) para las exportaciones. Esta configuración habilitará la sobrescritura de datos para el mismo mes en la cuenta de almacenamiento del cliente. De forma predeterminada, establezca en CreateNewReport.
|
|
properties.definition
|
ExportDefinition
|
Tiene la definición de la exportación.
|
|
properties.deliveryInfo
|
ExportDeliveryInfo
|
Tiene información de entrega para la exportación.
|
|
properties.exportDescription
|
string
|
Descripción de exportación establecida por el cliente en el momento de la creación o actualización de la exportación.
|
|
properties.format
|
FormatType
|
Formato de la exportación que se va a entregar.
|
|
properties.nextRunTimeEstimate
|
string
(date-time)
|
Si la exportación tiene una programación activa, proporciona una estimación del siguiente tiempo de ejecución.
|
|
properties.partitionData
|
boolean
|
Si se establece en true, los datos exportados se particionarán por tamaño y se colocarán en un directorio de blobs junto con un archivo de manifiesto.
|
|
properties.runHistory
|
ExportExecutionListResult
|
Si se solicita, tiene el historial de ejecución más reciente para la exportación.
|
|
properties.schedule
|
ExportSchedule
|
Tiene información de programación para la exportación.
|
|
properties.systemSuspensionContext
|
ExportSuspensionContext
|
Motivo de suspensión de exportación si la exportación está en estado SystemSuspended. Esto no está poblado actualmente.
|
|
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"
|
ExportDataset
Objeto
Definición de los datos de la exportación.
| Nombre |
Tipo |
Description |
|
configuration
|
ExportDatasetConfiguration
|
Configuración del conjunto de datos de exportación.
|
|
granularity
|
GranularityType
|
Granularidad de las filas de la exportación. Actualmente se admite "Daily" para la mayoría de los casos.
|
ExportDatasetConfiguration
Objeto
Esto está en ruta de desuso y no se admitirá en el futuro.
| Nombre |
Tipo |
Description |
|
columns
|
string[]
|
Matriz de nombres de columna que se van a incluir en la exportación. Si no se proporciona, la exportación incluirá todas las columnas disponibles. Las columnas disponibles pueden variar según el canal del cliente (consulte ejemplos).
|
|
dataVersion
|
string
|
Versión de datos de la opción seleccionada para la exportación. Si no se proporciona, la exportación tendrá como valor predeterminado la versión de datos más reciente.
|
|
filters
|
FilterItems[]
|
Filtros asociados a los conjuntos de datos.
|
ExportDefinition
Objeto
Definición de una exportación.
| Nombre |
Tipo |
Description |
|
dataSet
|
ExportDataset
|
Definición de los datos de la exportación.
|
|
timePeriod
|
ExportTimePeriod
|
Tiene un período de tiempo para extraer datos para la exportación.
|
|
timeframe
|
TimeframeType
|
Período de tiempo para extraer datos para la exportación. Si es personalizado, se debe proporcionar un período de tiempo específico.
|
|
type
|
ExportType
|
Tipo de la exportación. Tenga en cuenta que "Uso" es equivalente a "ActualCost" y es aplicable a las exportaciones que aún no proporcionan datos de cargos o amortización para las reservas de servicio.
|
ExportDeliveryDestination
Objeto
Esto representa la ubicación de la cuenta de Blob Storage donde se entregarán las exportaciones de costos. Hay dos maneras de configurar el destino. El enfoque recomendado para la mayoría de los clientes es especificar el resourceId de la cuenta de almacenamiento. Esto requiere un registro único de la suscripción de la cuenta con el proveedor de recursos Microsoft.CostManagementExports para conceder acceso a los servicios de Cost Management al almacenamiento. Al crear una exportación en Azure Portal, este registro se realiza automáticamente, pero es posible que los usuarios de la API necesiten registrar la suscripción explícitamente (para obtener más información, consulte https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services ). Otra manera de configurar el destino solo está disponible para los partners con un plan de Contrato de partners de Microsoft que sean administradores globales de su cuenta de facturación. Estos asociados, en lugar de especificar el resourceId de una cuenta de almacenamiento, pueden especificar el nombre de la cuenta de almacenamiento junto con un token de SAS para la cuenta. Esto permite las exportaciones de costos a una cuenta de almacenamiento en cualquier inquilino. El token de SAS debe crearse para el servicio de blobs con tipos de recursos Service/Container/Object y con permisos de lectura, escritura, eliminación, lista,agregar o crear (para obtener más información, consulte https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/export-cost-data-storage-account-sas-key ).
| Nombre |
Tipo |
Description |
|
container
|
string
|
Nombre del contenedor donde se cargarán las exportaciones. Si el contenedor no existe, se creará.
|
|
resourceId
|
string
|
Identificador de recurso de la cuenta de almacenamiento donde se entregarán las exportaciones. Esto no es necesario si se especifican sasToken y storageAccount.
|
|
rootFolderPath
|
string
|
Nombre del directorio donde se cargarán las exportaciones.
|
|
sasToken
|
string
(password)
|
Un token de SAS para la cuenta de almacenamiento. Para un conjunto restringido de clientes de Azure, esto se puede especificar junto con storageAccount en lugar de resourceId. Nota: el valor devuelto por la API para esta propiedad siempre se ofuscará. Devolver este mismo valor ofuscado no dará lugar a que se actualice el token de SAS. Para actualizar este valor, se debe especificar un nuevo token de SAS.
|
|
storageAccount
|
string
|
La cuenta de almacenamiento donde se cargarán las exportaciones. Para un conjunto restringido de clientes de Azure, esto se puede especificar junto con sasToken en lugar de resourceId.
|
|
type
|
DestinationType
|
Tipo de destino de entrega de exportación. Actualmente solo se admite "AzureBlob".
|
ExportDeliveryInfo
Objeto
Información de entrega asociada a una exportación.
ExportExecutionListResult
Objeto
Resultado de enumerar el historial de ejecución de una exportación.
| Nombre |
Tipo |
Description |
|
value
|
ExportRun[]
|
Lista de ejecuciones de exportación.
|
ExportRecurrencePeriod
Objeto
Fecha de inicio y finalización de la programación de periodicidad.
| Nombre |
Tipo |
Description |
|
from
|
string
(date-time)
|
Fecha de inicio de periodicidad.
|
|
to
|
string
(date-time)
|
Fecha de finalización de la periodicidad.
|
ExportRun
Objeto
Una ejecución de exportación.
| 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.
|
|
name
|
string
|
Nombre del recurso.
|
|
properties.endDate
|
string
(date-time)
|
Fecha y hora de finalización de la exportación.
|
|
properties.error
|
ErrorDetails
|
Detalles de cualquier error.
|
|
properties.executionType
|
ExecutionType
|
Tipo de la ejecución de exportación.
|
|
properties.fileName
|
string
|
Nombre del archivo exportado.
|
|
properties.manifestFile
|
string
|
Ubicación del archivo de manifiesto (ubicación del URI) para los archivos exportados.
|
|
properties.processingEndTime
|
string
(date-time)
|
Hora a la que finalizó la ejecución de exportación.
|
|
properties.processingStartTime
|
string
(date-time)
|
Hora en que se cogió la exportación para que se ejecutara.
|
|
properties.runSettings
|
CommonExportProperties
|
La configuración de exportación que estaba en vigor para esta ejecución.
|
|
properties.startDate
|
string
(date-time)
|
Fecha y hora de inicio para la exportación.
|
|
properties.status
|
ExecutionStatus
|
El último estado conocido de la ejecución de exportación.
|
|
properties.submittedBy
|
string
|
Identificador de la entidad que desencadenó la exportación. Para las ejecuciones a petición, es el correo electrónico del usuario. En el caso de las ejecuciones programadas, es "System".
|
|
properties.submittedTime
|
string
(date-time)
|
Hora en que se puso en cola la exportación para ejecutarse.
|
|
type
|
string
|
Tipo de recurso.
|
ExportSchedule
Objeto
Programación asociada a la exportación.
| Nombre |
Tipo |
Description |
|
recurrence
|
RecurrenceType
|
Periodicidad de la programación.
|
|
recurrencePeriod
|
ExportRecurrencePeriod
|
Tiene la fecha de inicio y finalización de la periodicidad. La fecha de inicio debe estar en el futuro. Si está presente, la fecha de finalización debe ser mayor que la fecha de inicio.
|
|
status
|
StatusType
|
Estado de la programación de la exportación. Si "Inactivo", se pausa la programación de la exportación. Para habilitar la exportación, establezca el estado como Activo y, a continuación, realice una solicitud PUT.
|
ExportSuspensionContext
Objeto
Propiedades de la ejecución de exportación. Esto no está poblado actualmente.
| Nombre |
Tipo |
Description |
|
suspensionCode
|
string
|
Código para la suspensión de exportación.
|
|
suspensionReason
|
string
|
Motivo detallado de la suspensión de exportación.
|
|
suspensionTime
|
string
(date-time)
|
Hora en que se suspendió la exportación.
|
ExportTimePeriod
Objeto
Intervalo de fechas para los datos de la exportación. Esto solo debe especificarse con timeFrame establecido en "Custom". El rango de fechas máximo es de 1 mes calendario.
| Nombre |
Tipo |
Description |
|
from
|
string
(date-time)
|
Fecha de inicio de los datos de exportación.
|
|
to
|
string
(date-time)
|
Fecha de finalización de los datos de exportación.
|
ExportType
Enumeración
Tipo de la exportación. Tenga en cuenta que "Uso" es equivalente a "ActualCost" y es aplicable a las exportaciones que aún no proporcionan datos de cargos o amortización para las reservas de servicio.
| Valor |
Description |
|
Usage
|
|
|
ActualCost
|
|
|
AmortizedCost
|
|
|
FocusCost
|
|
|
PriceSheet
|
|
|
ReservationTransactions
|
|
|
ReservationRecommendations
|
|
|
ReservationDetails
|
|
FilterItemNames
Enumeración
Nombre del filtro. Actualmente solo se admite para el tipo de definición de exportación de ReservationRecommendations. Los nombres admitidos son ['ReservationScope', 'LookBackPeriod', 'ResourceType']
| Valor |
Description |
|
ReservationScope
|
|
|
ResourceType
|
|
|
LookBackPeriod
|
|
FilterItems
Objeto
Contendrá el nombre del filtro y el valor en los que operar. Actualmente solo se admite para el tipo de definición de exportación de ReservationRecommendations.
| Nombre |
Tipo |
Description |
|
name
|
FilterItemNames
|
Nombre del filtro. Actualmente solo se admite para el tipo de definición de exportación de ReservationRecommendations. Los nombres admitidos son ['ReservationScope', 'LookBackPeriod', 'ResourceType']
|
|
value
|
string
|
Valor por el que se va a filtrar. Los valores admitidos actualmente por nombre son, para los valores admitidos "ReservationScope" son ['Single', 'Shared'], para los valores admitidos de 'LookBackPeriod' son ['Last7Days', 'Last30Days', 'Last60Days'] y para los valores admitidos 'ResourceType' son ['VirtualMachines', 'SQLDatabases', 'PostgreSQL', 'ManagedDisk', 'MySQL', 'RedHat', 'MariaDB', 'RedisCache', 'CosmosDB', 'SqlDataWarehouse', 'SUSELinux', 'AppService', 'BlockBlob', 'AzureDataExplorer', 'VMwareCloudSimple'].
|
Enumeración
Formato de la exportación que se va a entregar.
| Valor |
Description |
|
Csv
|
|
|
Parquet
|
|
GranularityType
Enumeración
Granularidad de las filas de la exportación. Actualmente se admite "Daily" para la mayoría de los casos.
| Valor |
Description |
|
Daily
|
|
|
Monthly
|
|
RecurrenceType
Enumeración
Periodicidad de la programación.
| Valor |
Description |
|
Daily
|
|
|
Weekly
|
|
|
Monthly
|
|
|
Annually
|
|
StatusType
Enumeración
Estado de la programación de la exportación. Si "Inactivo", se pausa la programación de la exportación. Para habilitar la exportación, establezca el estado como Activo y, a continuación, realice una solicitud PUT.
| Valor |
Description |
|
Active
|
|
|
Inactive
|
|
SystemAssignedServiceIdentity
Objeto
Identidad de servicio administrada (asignada por el sistema o ninguna)
| Nombre |
Tipo |
Description |
|
principalId
|
string
(uuid)
|
Identificador de entidad de servicio de la identidad asignada por el sistema. Esta propiedad solo se proporcionará para una identidad asignada por el sistema.
|
|
tenantId
|
string
(uuid)
|
Identificador de inquilino de la identidad asignada por el sistema. Esta propiedad solo se proporcionará para una identidad asignada por el sistema.
|
|
type
|
SystemAssignedServiceIdentityType
|
Tipo de identidad de servicio administrada (asignada por el sistema o ninguna).
|
SystemAssignedServiceIdentityType
Enumeración
Tipo de identidad de servicio administrada (asignada por el sistema o ninguna).
| Valor |
Description |
|
None
|
|
|
SystemAssigned
|
|
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
|
Identidad que modificó por última vez el recurso.
|
|
lastModifiedByType
|
createdByType
|
Tipo de identidad que modificó por última vez el recurso.
|
TimeframeType
Enumeración
Período de tiempo para extraer datos para la exportación. Si es personalizado, se debe proporcionar un período de tiempo específico.
| Valor |
Description |
|
MonthToDate
|
|
|
BillingMonthToDate
|
|
|
TheLastMonth
|
|
|
TheLastBillingMonth
|
|
|
WeekToDate
|
|
|
Custom
|
|
|
TheCurrentMonth
|
|