Operazione per creare o aggiornare un'esportazione. L'operazione di aggiornamento richiede l'impostazione dell'eTag più recente nella richiesta. È possibile ottenere l'eTag più recente eseguendo un'operazione get. L'operazione di creazione non richiede eTag.
PUT https://management.azure.com/{scope}/providers/Microsoft.CostManagement/exports/{exportName}?api-version=2025-03-01
Parametri dell'URI
| Nome |
In |
Necessario |
Tipo |
Descrizione |
|
exportName
|
path |
True
|
string
|
Nome esportazione.
|
|
scope
|
path |
True
|
string
|
Identificatore completo di Azure Resource Manager della risorsa.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
Versione dell'API da usare per questa operazione.
|
Corpo della richiesta
| Nome |
Necessario |
Tipo |
Descrizione |
|
properties.definition
|
True
|
ExportDefinition
|
Ha la definizione per l'esportazione.
|
|
properties.deliveryInfo
|
True
|
ExportDeliveryInfo
|
Contiene informazioni sul recapito per l'esportazione.
|
|
eTag
|
|
string
|
eTag della risorsa. Per gestire lo scenario di aggiornamento simultaneo, questo campo verrà usato per determinare se l'utente sta aggiornando o meno la versione più recente.
|
|
identity
|
|
SystemAssignedServiceIdentity
|
Identità gestita associata all'esportazione
|
|
location
|
|
string
|
Posizione dell'identità gestita dell'esportazione. Obbligatorio solo quando si usa l'identità gestita.
|
|
properties.compressionMode
|
|
CompressionModeType
|
Consentire ai clienti di selezionare comprimere i dati per le esportazioni. Questa impostazione abiliterà lo schema di compressione dei file di destinazione in fase di esecuzione. Per impostazione predefinita, impostare su Nessuno. Gzip è per csv e snappy per parquet.
|
|
properties.dataOverwriteBehavior
|
|
DataOverwriteBehaviorType
|
Consenti ai clienti di selezionare overwrite data(OverwritePreviousReport) per le esportazioni. Questa impostazione consentirà di sovrascrivere i dati per lo stesso mese nell'account di archiviazione del cliente. Per impostazione predefinita, impostare su CreateNewReport.
|
|
properties.exportDescription
|
|
string
|
Descrizione dell'esportazione impostata dal cliente al momento della creazione/aggiornamento dell'esportazione.
|
|
properties.format
|
|
FormatType
|
Formato dell'esportazione recapitata.
|
|
properties.partitionData
|
|
boolean
|
Se impostato su true, i dati esportati verranno partizionati in base alle dimensioni e inseriti in una directory BLOB insieme a un file manifesto.
|
|
properties.runHistory
|
|
ExportExecutionListResult
|
Se richiesto, ha la cronologia di esecuzione più recente per l'esportazione.
|
|
properties.schedule
|
|
ExportSchedule
|
Contiene informazioni sulla pianificazione per l'esportazione.
|
Risposte
| Nome |
Tipo |
Descrizione |
|
200 OK
|
Export
|
Operazione di aggiornamento 'Esportazione' della risorsa riuscita
|
|
201 Created
|
Export
|
Risorsa 'Esporta' crea operazione riuscita
|
|
Other Status Codes
|
ErrorResponse
|
Risposta di errore imprevista.
|
Sicurezza
azure_auth
Flusso OAuth2 di Azure Active Directory.
Tipo:
oauth2
Flow:
implicit
URL di autorizzazione:
https://login.microsoftonline.com/common/oauth2/authorize
Ambiti
| Nome |
Descrizione |
|
user_impersonation
|
rappresentare l'account utente
|
Esempio
ExportCreateOrUpdateByBillingAccount
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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"
}
}
}
Definizioni
| Nome |
Descrizione |
|
CommonExportProperties
|
Proprietà comuni dell'esportazione.
|
|
CompressionModeType
|
Consentire ai clienti di selezionare comprimere i dati per le esportazioni. Questa impostazione abiliterà lo schema di compressione dei file di destinazione in fase di esecuzione. Per impostazione predefinita, impostare su Nessuno. Gzip è per csv e snappy per parquet.
|
|
createdByType
|
Tipo di identità che ha creato la risorsa.
|
|
DataOverwriteBehaviorType
|
Consenti ai clienti di selezionare overwrite data(OverwritePreviousReport) per le esportazioni. Questa impostazione consentirà di sovrascrivere i dati per lo stesso mese nell'account di archiviazione del cliente. Per impostazione predefinita, impostare su CreateNewReport.
|
|
DestinationType
|
Tipo di destinazione del recapito dell'esportazione. Attualmente è supportato solo "AzureBlob".
|
|
ErrorDetails
|
Dettagli dell'errore.
|
|
ErrorResponse
|
La risposta di errore indica che il servizio non è in grado di elaborare la richiesta in ingresso. Il motivo viene fornito nel messaggio di errore. \n\nAlcune risposte agli errori: \n\n * 429 TooManyRequests - La richiesta è limitata. Riprovare dopo aver aspettato il tempo specificato nell'intestazione "x-ms-ratelimit-microsoft.consumption-retry-after". \n\n * 503 ServiceUnavailable - Il servizio è temporaneamente non disponibile. Riprovare dopo aver aspettato il tempo specificato nell'intestazione "Retry-After".
|
|
ExecutionStatus
|
Ultimo stato noto dell'esecuzione dell'esportazione.
|
|
ExecutionType
|
Tipo dell'esecuzione dell'esportazione.
|
|
Export
|
Una risorsa di esportazione.
|
|
ExportDataset
|
Definizione per i dati nell'esportazione.
|
|
ExportDatasetConfiguration
|
Si tratta di un percorso di deprecazione e non sarà supportato in futuro.
|
|
ExportDefinition
|
Definizione di un'esportazione.
|
|
ExportDeliveryDestination
|
Rappresenta il percorso dell'account di archiviazione BLOB in cui verranno recapitate le esportazioni dei costi. Esistono due modi per configurare la destinazione. L'approccio consigliato per la maggior parte dei clienti consiste nel specificare il valore resourceId dell'account di archiviazione. Ciò richiede una registrazione una tantum della sottoscrizione dell'account con il provider di risorse Microsoft.CostManagementExports per concedere ai servizi gestione costi l'accesso all'archiviazione. Quando si crea un'esportazione nel portale di Azure, questa registrazione viene eseguita automaticamente, ma gli utenti dell'API potrebbero dover registrare la sottoscrizione in modo esplicito (per altre informazioni, vedere https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services ). Un altro modo per configurare la destinazione è disponibile SOLO per i partner con un piano del Contratto Microsoft Partner che sono amministratori globali dell'account di fatturazione. Questi partner, invece di specificare il valore resourceId di un account di archiviazione, possono specificare il nome dell'account di archiviazione insieme a un token di firma di accesso condiviso per l'account. In questo modo è possibile esportare i costi in un account di archiviazione in qualsiasi tenant. Il token di firma di accesso condiviso deve essere creato per il servizio BLOB con tipi di risorse Service/Container/Object e con autorizzazioni lettura/scrittura/eliminazione/elenco/aggiunta/creazione (per altre informazioni, vedere https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/export-cost-data-storage-account-sas-key ).
|
|
ExportDeliveryInfo
|
Informazioni sul recapito associate a un'esportazione.
|
|
ExportExecutionListResult
|
Risultato dell'elenco della cronologia di esecuzione di un'esportazione.
|
|
ExportRecurrencePeriod
|
Data di inizio e fine per la pianificazione della ricorrenza.
|
|
ExportRun
|
Esecuzione di esportazione.
|
|
ExportSchedule
|
Pianificazione associata all'esportazione.
|
|
ExportSuspensionContext
|
Proprietà dell'esecuzione dell'esportazione. Al momento non è popolato.
|
|
ExportTimePeriod
|
Intervallo di date per i dati nell'esportazione. Questa opzione deve essere specificata solo con intervallo di tempo impostato su "Personalizzato". L'intervallo di date massimo è di 1 mese di calendario.
|
|
ExportType
|
Tipo dell'esportazione. Si noti che "Usage" equivale a "ActualCost" ed è applicabile alle esportazioni che non forniscono ancora dati per gli addebiti o l'ammortamento per le prenotazioni del servizio.
|
|
FilterItemNames
|
Il nome del filtro. Questa opzione è attualmente supportata solo per il tipo di definizione di esportazione di ReservationRecommendations. I nomi supportati sono ['ReservationScope', 'LookBackPeriod', 'ResourceType']
|
|
FilterItems
|
Conterrà il nome e il valore del filtro su cui operare. Questa opzione è attualmente supportata solo per il tipo di definizione di esportazione di ReservationRecommendations.
|
|
FormatType
|
Formato dell'esportazione recapitata.
|
|
GranularityType
|
Granularità delle righe nell'esportazione. Attualmente "Daily" è supportato per la maggior parte dei casi.
|
|
RecurrenceType
|
Ricorrenza della pianificazione.
|
|
StatusType
|
Stato della pianificazione dell'esportazione. Se "Inattivo", la pianificazione dell'esportazione viene sospesa. Per abilitare l'esportazione, impostare lo stato su Attivo e quindi effettuare una richiesta PUT.
|
|
SystemAssignedServiceIdentity
|
Identità del servizio gestito (assegnata dal sistema o nessuna)
|
|
SystemAssignedServiceIdentityType
|
Tipo di identità del servizio gestito (assegnata dal sistema o nessuna).
|
|
systemData
|
Metadati relativi alla creazione e all'ultima modifica della risorsa.
|
|
TimeframeType
|
Intervallo di tempo per il pull dei dati per l'esportazione. Se personalizzato, è necessario specificare un periodo di tempo specifico.
|
CommonExportProperties
Oggetto
Proprietà comuni dell'esportazione.
| Nome |
Tipo |
Descrizione |
|
compressionMode
|
CompressionModeType
|
Consentire ai clienti di selezionare comprimere i dati per le esportazioni. Questa impostazione abiliterà lo schema di compressione dei file di destinazione in fase di esecuzione. Per impostazione predefinita, impostare su Nessuno. Gzip è per csv e snappy per parquet.
|
|
dataOverwriteBehavior
|
DataOverwriteBehaviorType
|
Consenti ai clienti di selezionare overwrite data(OverwritePreviousReport) per le esportazioni. Questa impostazione consentirà di sovrascrivere i dati per lo stesso mese nell'account di archiviazione del cliente. Per impostazione predefinita, impostare su CreateNewReport.
|
|
definition
|
ExportDefinition
|
Ha la definizione per l'esportazione.
|
|
deliveryInfo
|
ExportDeliveryInfo
|
Contiene informazioni sul recapito per l'esportazione.
|
|
exportDescription
|
string
|
Descrizione dell'esportazione impostata dal cliente al momento della creazione/aggiornamento dell'esportazione.
|
|
format
|
FormatType
|
Formato dell'esportazione recapitata.
|
|
nextRunTimeEstimate
|
string
(date-time)
|
Se l'esportazione ha una pianificazione attiva, fornisce una stima del tempo di esecuzione successivo.
|
|
partitionData
|
boolean
|
Se impostato su true, i dati esportati verranno partizionati in base alle dimensioni e inseriti in una directory BLOB insieme a un file manifesto.
|
|
runHistory
|
ExportExecutionListResult
|
Se richiesto, ha la cronologia di esecuzione più recente per l'esportazione.
|
|
systemSuspensionContext
|
ExportSuspensionContext
|
Motivo della sospensione dell'esportazione se l'esportazione è in stato SystemSuspended. Al momento non è popolato.
|
CompressionModeType
Enumerazione
Consentire ai clienti di selezionare comprimere i dati per le esportazioni. Questa impostazione abiliterà lo schema di compressione dei file di destinazione in fase di esecuzione. Per impostazione predefinita, impostare su Nessuno. Gzip è per csv e snappy per parquet.
| Valore |
Descrizione |
|
gzip
|
|
|
snappy
|
|
|
none
|
|
createdByType
Enumerazione
Tipo di identità che ha creato la risorsa.
| Valore |
Descrizione |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
DataOverwriteBehaviorType
Enumerazione
Consenti ai clienti di selezionare overwrite data(OverwritePreviousReport) per le esportazioni. Questa impostazione consentirà di sovrascrivere i dati per lo stesso mese nell'account di archiviazione del cliente. Per impostazione predefinita, impostare su CreateNewReport.
| Valore |
Descrizione |
|
OverwritePreviousReport
|
|
|
CreateNewReport
|
|
DestinationType
Enumerazione
Tipo di destinazione del recapito dell'esportazione. Attualmente è supportato solo "AzureBlob".
| Valore |
Descrizione |
|
AzureBlob
|
|
ErrorDetails
Oggetto
Dettagli dell'errore.
| Nome |
Tipo |
Descrizione |
|
code
|
string
|
Codice di errore.
|
|
message
|
string
|
Messaggio di errore che indica il motivo per cui l'operazione non è riuscita.
|
ErrorResponse
Oggetto
La risposta di errore indica che il servizio non è in grado di elaborare la richiesta in ingresso. Il motivo viene fornito nel messaggio di errore. \n\nAlcune risposte agli errori: \n\n * 429 TooManyRequests - La richiesta è limitata. Riprovare dopo aver aspettato il tempo specificato nell'intestazione "x-ms-ratelimit-microsoft.consumption-retry-after". \n\n * 503 ServiceUnavailable - Il servizio è temporaneamente non disponibile. Riprovare dopo aver aspettato il tempo specificato nell'intestazione "Retry-After".
| Nome |
Tipo |
Descrizione |
|
error
|
ErrorDetails
|
Dettagli dell'errore.
|
ExecutionStatus
Enumerazione
Ultimo stato noto dell'esecuzione dell'esportazione.
| Valore |
Descrizione |
|
Queued
|
|
|
InProgress
|
|
|
Completed
|
|
|
Failed
|
|
|
Timeout
|
|
|
NewDataNotAvailable
|
|
|
DataNotAvailable
|
|
ExecutionType
Enumerazione
Tipo dell'esecuzione dell'esportazione.
| Valore |
Descrizione |
|
OnDemand
|
|
|
Scheduled
|
|
Export
Oggetto
Una risorsa di esportazione.
| Nome |
Tipo |
Descrizione |
|
eTag
|
string
|
eTag della risorsa. Per gestire lo scenario di aggiornamento simultaneo, questo campo verrà usato per determinare se l'utente sta aggiornando o meno la versione più recente.
|
|
id
|
string
(arm-id)
|
ID risorsa completo per la risorsa. Ad esempio, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
identity
|
SystemAssignedServiceIdentity
|
Identità gestita associata all'esportazione
|
|
location
|
string
|
Posizione dell'identità gestita dell'esportazione. Obbligatorio solo quando si usa l'identità gestita.
|
|
name
|
string
|
Nome della risorsa
|
|
properties.compressionMode
|
CompressionModeType
|
Consentire ai clienti di selezionare comprimere i dati per le esportazioni. Questa impostazione abiliterà lo schema di compressione dei file di destinazione in fase di esecuzione. Per impostazione predefinita, impostare su Nessuno. Gzip è per csv e snappy per parquet.
|
|
properties.dataOverwriteBehavior
|
DataOverwriteBehaviorType
|
Consenti ai clienti di selezionare overwrite data(OverwritePreviousReport) per le esportazioni. Questa impostazione consentirà di sovrascrivere i dati per lo stesso mese nell'account di archiviazione del cliente. Per impostazione predefinita, impostare su CreateNewReport.
|
|
properties.definition
|
ExportDefinition
|
Ha la definizione per l'esportazione.
|
|
properties.deliveryInfo
|
ExportDeliveryInfo
|
Contiene informazioni sul recapito per l'esportazione.
|
|
properties.exportDescription
|
string
|
Descrizione dell'esportazione impostata dal cliente al momento della creazione/aggiornamento dell'esportazione.
|
|
properties.format
|
FormatType
|
Formato dell'esportazione recapitata.
|
|
properties.nextRunTimeEstimate
|
string
(date-time)
|
Se l'esportazione ha una pianificazione attiva, fornisce una stima del tempo di esecuzione successivo.
|
|
properties.partitionData
|
boolean
|
Se impostato su true, i dati esportati verranno partizionati in base alle dimensioni e inseriti in una directory BLOB insieme a un file manifesto.
|
|
properties.runHistory
|
ExportExecutionListResult
|
Se richiesto, ha la cronologia di esecuzione più recente per l'esportazione.
|
|
properties.schedule
|
ExportSchedule
|
Contiene informazioni sulla pianificazione per l'esportazione.
|
|
properties.systemSuspensionContext
|
ExportSuspensionContext
|
Motivo della sospensione dell'esportazione se l'esportazione è in stato SystemSuspended. Al momento non è popolato.
|
|
systemData
|
systemData
|
Metadati di Azure Resource Manager contenenti le informazioni createdBy e modifiedBy.
|
|
type
|
string
|
Tipo di risorsa. Ad esempio, "Microsoft.Compute/virtualMachines" o "Microsoft.Storage/storageAccounts"
|
ExportDataset
Oggetto
Definizione per i dati nell'esportazione.
| Nome |
Tipo |
Descrizione |
|
configuration
|
ExportDatasetConfiguration
|
Configurazione del set di dati di esportazione.
|
|
granularity
|
GranularityType
|
Granularità delle righe nell'esportazione. Attualmente "Daily" è supportato per la maggior parte dei casi.
|
ExportDatasetConfiguration
Oggetto
Si tratta di un percorso di deprecazione e non sarà supportato in futuro.
| Nome |
Tipo |
Descrizione |
|
columns
|
string[]
|
Matrice di nomi di colonna da includere nell'esportazione. Se non specificato, l'esportazione includerà tutte le colonne disponibili. Le colonne disponibili possono variare in base al canale del cliente (vedere esempi).
|
|
dataVersion
|
string
|
Versione dei dati per l'oggetto selezionato per l'esportazione. Se non specificato, per impostazione predefinita l'esportazione sarà la versione più recente dei dati.
|
|
filters
|
FilterItems[]
|
Filtri associati ai set di dati.
|
ExportDefinition
Oggetto
Definizione di un'esportazione.
| Nome |
Tipo |
Descrizione |
|
dataSet
|
ExportDataset
|
Definizione per i dati nell'esportazione.
|
|
timePeriod
|
ExportTimePeriod
|
Periodo di tempo per il pull dei dati per l'esportazione.
|
|
timeframe
|
TimeframeType
|
Intervallo di tempo per il pull dei dati per l'esportazione. Se personalizzato, è necessario specificare un periodo di tempo specifico.
|
|
type
|
ExportType
|
Tipo dell'esportazione. Si noti che "Usage" equivale a "ActualCost" ed è applicabile alle esportazioni che non forniscono ancora dati per gli addebiti o l'ammortamento per le prenotazioni del servizio.
|
ExportDeliveryDestination
Oggetto
Rappresenta il percorso dell'account di archiviazione BLOB in cui verranno recapitate le esportazioni dei costi. Esistono due modi per configurare la destinazione. L'approccio consigliato per la maggior parte dei clienti consiste nel specificare il valore resourceId dell'account di archiviazione. Ciò richiede una registrazione una tantum della sottoscrizione dell'account con il provider di risorse Microsoft.CostManagementExports per concedere ai servizi gestione costi l'accesso all'archiviazione. Quando si crea un'esportazione nel portale di Azure, questa registrazione viene eseguita automaticamente, ma gli utenti dell'API potrebbero dover registrare la sottoscrizione in modo esplicito (per altre informazioni, vedere https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services ). Un altro modo per configurare la destinazione è disponibile SOLO per i partner con un piano del Contratto Microsoft Partner che sono amministratori globali dell'account di fatturazione. Questi partner, invece di specificare il valore resourceId di un account di archiviazione, possono specificare il nome dell'account di archiviazione insieme a un token di firma di accesso condiviso per l'account. In questo modo è possibile esportare i costi in un account di archiviazione in qualsiasi tenant. Il token di firma di accesso condiviso deve essere creato per il servizio BLOB con tipi di risorse Service/Container/Object e con autorizzazioni lettura/scrittura/eliminazione/elenco/aggiunta/creazione (per altre informazioni, vedere https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/export-cost-data-storage-account-sas-key ).
| Nome |
Tipo |
Descrizione |
|
container
|
string
|
Nome del contenitore in cui verranno caricate le esportazioni. Se il contenitore non esiste, verrà creato.
|
|
resourceId
|
string
|
ID risorsa dell'account di archiviazione in cui verranno recapitate le esportazioni. Questa operazione non è necessaria se vengono specificati sasToken e storageAccount.
|
|
rootFolderPath
|
string
|
Nome della directory in cui verranno caricate le esportazioni.
|
|
sasToken
|
string
(password)
|
Token di firma di accesso condiviso per l'account di archiviazione. Per un set limitato di clienti di Azure, questo insieme a storageAccount può essere specificato invece di resourceId. Nota: il valore restituito dall'API per questa proprietà verrà sempre offuscato. La restituzione dello stesso valore offuscato non comporterà l'aggiornamento del token di firma di accesso condiviso. Per aggiornare questo valore, è necessario specificare un nuovo token di firma di accesso condiviso.
|
|
storageAccount
|
string
|
Account di archiviazione in cui verranno caricate le esportazioni. Per un set limitato di clienti di Azure, questo insieme a sasToken può essere specificato invece di resourceId.
|
|
type
|
DestinationType
|
Tipo di destinazione del recapito dell'esportazione. Attualmente è supportato solo "AzureBlob".
|
ExportDeliveryInfo
Oggetto
Informazioni sul recapito associate a un'esportazione.
ExportExecutionListResult
Oggetto
Risultato dell'elenco della cronologia di esecuzione di un'esportazione.
| Nome |
Tipo |
Descrizione |
|
value
|
ExportRun[]
|
Elenco di esecuzioni di esportazione.
|
ExportRecurrencePeriod
Oggetto
Data di inizio e fine per la pianificazione della ricorrenza.
| Nome |
Tipo |
Descrizione |
|
from
|
string
(date-time)
|
Data di inizio della ricorrenza.
|
|
to
|
string
(date-time)
|
Data di fine della ricorrenza.
|
ExportRun
Oggetto
Esecuzione di esportazione.
| Nome |
Tipo |
Descrizione |
|
eTag
|
string
|
eTag della risorsa. Per gestire lo scenario di aggiornamento simultaneo, questo campo verrà usato per determinare se l'utente sta aggiornando o meno la versione più recente.
|
|
id
|
string
|
ID risorsa.
|
|
name
|
string
|
Nome risorsa.
|
|
properties.endDate
|
string
(date-time)
|
Data/ora di fine per l'esportazione.
|
|
properties.error
|
ErrorDetails
|
Dettagli di qualsiasi errore.
|
|
properties.executionType
|
ExecutionType
|
Tipo dell'esecuzione dell'esportazione.
|
|
properties.fileName
|
string
|
Nome del file esportato.
|
|
properties.manifestFile
|
string
|
Percorso del file manifesto (percorso URI) per i file esportati.
|
|
properties.processingEndTime
|
string
(date-time)
|
Ora di fine dell'esecuzione dell'esportazione.
|
|
properties.processingStartTime
|
string
(date-time)
|
Ora in cui l'esportazione è stata prelevata per l'esecuzione.
|
|
properties.runSettings
|
CommonExportProperties
|
Impostazioni di esportazione applicate per l'esecuzione.
|
|
properties.startDate
|
string
(date-time)
|
Data/ora di inizio per l'esportazione.
|
|
properties.status
|
ExecutionStatus
|
Ultimo stato noto dell'esecuzione dell'esportazione.
|
|
properties.submittedBy
|
string
|
Identificatore dell'entità che ha attivato l'esportazione. Per l'esecuzione su richiesta, si tratta del messaggio di posta elettronica dell'utente. Per le esecuzioni pianificate, è "System".
|
|
properties.submittedTime
|
string
(date-time)
|
Ora in cui l'esportazione è stata accodata per l'esecuzione.
|
|
type
|
string
|
Tipo di risorsa.
|
ExportSchedule
Oggetto
Pianificazione associata all'esportazione.
| Nome |
Tipo |
Descrizione |
|
recurrence
|
RecurrenceType
|
Ricorrenza della pianificazione.
|
|
recurrencePeriod
|
ExportRecurrencePeriod
|
Ha la data di inizio e di fine della ricorrenza. La data di inizio deve essere futura. Se presente, la data di fine deve essere maggiore della data di inizio.
|
|
status
|
StatusType
|
Stato della pianificazione dell'esportazione. Se "Inattivo", la pianificazione dell'esportazione viene sospesa. Per abilitare l'esportazione, impostare lo stato su Attivo e quindi effettuare una richiesta PUT.
|
ExportSuspensionContext
Oggetto
Proprietà dell'esecuzione dell'esportazione. Al momento non è popolato.
| Nome |
Tipo |
Descrizione |
|
suspensionCode
|
string
|
Codice per la sospensione dell'esportazione.
|
|
suspensionReason
|
string
|
Motivo dettagliato della sospensione dell'esportazione.
|
|
suspensionTime
|
string
(date-time)
|
Ora in cui l'esportazione è stata sospesa.
|
ExportTimePeriod
Oggetto
Intervallo di date per i dati nell'esportazione. Questa opzione deve essere specificata solo con intervallo di tempo impostato su "Personalizzato". L'intervallo di date massimo è di 1 mese di calendario.
| Nome |
Tipo |
Descrizione |
|
from
|
string
(date-time)
|
Data di inizio per l'esportazione dei dati.
|
|
to
|
string
(date-time)
|
Data di fine per l'esportazione dei dati.
|
ExportType
Enumerazione
Tipo dell'esportazione. Si noti che "Usage" equivale a "ActualCost" ed è applicabile alle esportazioni che non forniscono ancora dati per gli addebiti o l'ammortamento per le prenotazioni del servizio.
| Valore |
Descrizione |
|
Usage
|
|
|
ActualCost
|
|
|
AmortizedCost
|
|
|
FocusCost
|
|
|
PriceSheet
|
|
|
ReservationTransactions
|
|
|
ReservationRecommendations
|
|
|
ReservationDetails
|
|
FilterItemNames
Enumerazione
Il nome del filtro. Questa opzione è attualmente supportata solo per il tipo di definizione di esportazione di ReservationRecommendations. I nomi supportati sono ['ReservationScope', 'LookBackPeriod', 'ResourceType']
| Valore |
Descrizione |
|
ReservationScope
|
|
|
ResourceType
|
|
|
LookBackPeriod
|
|
FilterItems
Oggetto
Conterrà il nome e il valore del filtro su cui operare. Questa opzione è attualmente supportata solo per il tipo di definizione di esportazione di ReservationRecommendations.
| Nome |
Tipo |
Descrizione |
|
name
|
FilterItemNames
|
Il nome del filtro. Questa opzione è attualmente supportata solo per il tipo di definizione di esportazione di ReservationRecommendations. I nomi supportati sono ['ReservationScope', 'LookBackPeriod', 'ResourceType']
|
|
value
|
string
|
Valore per cui filtrare. Attualmente i valori supportati per nome sono, per i valori supportati di 'ReservationScope' sono ['Single', 'Shared'], per i valori supportati di 'LookBackPeriod' sono ['Last7Days', 'Last30Days', 'Last60Days'] e per i valori supportati di 'ResourceType' sono ['VirtualMachines', 'SQLDatabases', 'PostgreSQL', 'ManagedDisk', 'MySQL', 'RedHat', 'MariaDB', 'RedisCache', 'CosmosDB', 'SqlDataWarehouse', 'SUSELinux', 'AppService', 'BlockBlob', 'AzureDataExplorer', 'VMwareCloudSimple'].
|
Enumerazione
Formato dell'esportazione recapitata.
| Valore |
Descrizione |
|
Csv
|
|
|
Parquet
|
|
GranularityType
Enumerazione
Granularità delle righe nell'esportazione. Attualmente "Daily" è supportato per la maggior parte dei casi.
| Valore |
Descrizione |
|
Daily
|
|
|
Monthly
|
|
RecurrenceType
Enumerazione
Ricorrenza della pianificazione.
| Valore |
Descrizione |
|
Daily
|
|
|
Weekly
|
|
|
Monthly
|
|
|
Annually
|
|
StatusType
Enumerazione
Stato della pianificazione dell'esportazione. Se "Inattivo", la pianificazione dell'esportazione viene sospesa. Per abilitare l'esportazione, impostare lo stato su Attivo e quindi effettuare una richiesta PUT.
| Valore |
Descrizione |
|
Active
|
|
|
Inactive
|
|
SystemAssignedServiceIdentity
Oggetto
Identità del servizio gestito (assegnata dal sistema o nessuna)
| Nome |
Tipo |
Descrizione |
|
principalId
|
string
(uuid)
|
ID entità servizio dell'identità assegnata dal sistema. Questa proprietà verrà fornita solo per un'identità assegnata dal sistema.
|
|
tenantId
|
string
(uuid)
|
ID tenant dell'identità assegnata dal sistema. Questa proprietà verrà fornita solo per un'identità assegnata dal sistema.
|
|
type
|
SystemAssignedServiceIdentityType
|
Tipo di identità del servizio gestito (assegnata dal sistema o nessuna).
|
SystemAssignedServiceIdentityType
Enumerazione
Tipo di identità del servizio gestito (assegnata dal sistema o nessuna).
| Valore |
Descrizione |
|
None
|
|
|
SystemAssigned
|
|
systemData
Oggetto
Metadati relativi alla creazione e all'ultima modifica della risorsa.
| Nome |
Tipo |
Descrizione |
|
createdAt
|
string
(date-time)
|
Timestamp della creazione della risorsa (UTC).
|
|
createdBy
|
string
|
Identità che ha creato la risorsa.
|
|
createdByType
|
createdByType
|
Tipo di identità che ha creato la risorsa.
|
|
lastModifiedAt
|
string
(date-time)
|
Il timestamp dell'ultima modifica della risorsa (UTC)
|
|
lastModifiedBy
|
string
|
Identità che ha modificato l'ultima volta la risorsa.
|
|
lastModifiedByType
|
createdByType
|
Tipo di identità che ha modificato l'ultima volta la risorsa.
|
TimeframeType
Enumerazione
Intervallo di tempo per il pull dei dati per l'esportazione. Se personalizzato, è necessario specificare un periodo di tempo specifico.
| Valore |
Descrizione |
|
MonthToDate
|
|
|
BillingMonthToDate
|
|
|
TheLastMonth
|
|
|
TheLastBillingMonth
|
|
|
WeekToDate
|
|
|
Custom
|
|
|
TheCurrentMonth
|
|