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.
PUT https://management.azure.com/{scope}/providers/Microsoft.CostManagement/exports/{exportName}?api-version=2025-03-01
URI Parameters
| Name |
In |
Required |
Type |
Description |
|
exportName
|
path |
True
|
string
|
Export Name.
|
|
scope
|
path |
True
|
string
|
The fully qualified Azure Resource manager identifier of the resource.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
The API version to use for this operation.
|
Request Body
| Name |
Required |
Type |
Description |
|
properties.definition
|
True
|
ExportDefinition
|
Has the definition for the export.
|
|
properties.deliveryInfo
|
True
|
ExportDeliveryInfo
|
Has delivery information for the export.
|
|
eTag
|
|
string
|
eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.
|
|
identity
|
|
SystemAssignedServiceIdentity
|
The managed identity associated with Export
|
|
location
|
|
string
|
The location of the Export's managed identity. Only required when utilizing managed identity.
|
|
properties.compressionMode
|
|
CompressionModeType
|
Allow customers to select compress data for exports. This setting will enable destination file compression scheme at runtime. By default set to None. Gzip is for csv and snappy for parquet.
|
|
properties.dataOverwriteBehavior
|
|
DataOverwriteBehaviorType
|
Allow customers to select overwrite data(OverwritePreviousReport) for exports. This setting will enable overwrite data for the same month in customer storage account. By default set to CreateNewReport.
|
|
properties.exportDescription
|
|
string
|
The export description set by customer at time of export creation/update.
|
|
properties.format
|
|
FormatType
|
The format of the export being delivered.
|
|
properties.partitionData
|
|
boolean
|
If set to true, exported data will be partitioned by size and placed in a blob directory together with a manifest file.
|
|
properties.runHistory
|
|
ExportExecutionListResult
|
If requested, has the most recent run history for the export.
|
|
properties.schedule
|
|
ExportSchedule
|
Has schedule information for the export.
|
Responses
| Name |
Type |
Description |
|
200 OK
|
Export
|
Resource 'Export' update operation succeeded
|
|
201 Created
|
Export
|
Resource 'Export' create operation succeeded
|
|
Other Status Codes
|
ErrorResponse
|
An unexpected error response.
|
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
| Name |
Description |
|
user_impersonation
|
impersonate your user account
|
Examples
ExportCreateOrUpdateByBillingAccount
Sample request
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
Sample response
{
"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
Sample request
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
Sample response
{
"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
Sample request
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
Sample response
{
"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
Sample request
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
Sample response
{
"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
Sample request
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
Sample response
{
"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
Sample request
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
Sample response
{
"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
Sample request
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
Sample response
{
"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
Sample request
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
Sample response
{
"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
Sample request
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
Sample response
{
"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
Sample request
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
Sample response
{
"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
Sample request
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
Sample response
{
"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
Sample request
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
Sample response
{
"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"
}
}
}
Definitions
| Name |
Description |
|
CommonExportProperties
|
The common properties of the export.
|
|
CompressionModeType
|
Allow customers to select compress data for exports. This setting will enable destination file compression scheme at runtime. By default set to None. Gzip is for csv and snappy for parquet.
|
|
createdByType
|
The type of identity that created the resource.
|
|
DataOverwriteBehaviorType
|
Allow customers to select overwrite data(OverwritePreviousReport) for exports. This setting will enable overwrite data for the same month in customer storage account. By default set to CreateNewReport.
|
|
DestinationType
|
The export delivery destination type. Currently only 'AzureBlob' is supported.
|
|
ErrorDetails
|
The details of the error.
|
|
ErrorResponse
|
Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. \n\nSome Error responses: \n\n * 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" header. \n\n * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" header.
|
|
ExecutionStatus
|
The last known status of the export run.
|
|
ExecutionType
|
The type of the export run.
|
|
Export
|
An export resource.
|
|
ExportDataset
|
The definition for data in the export.
|
|
ExportDatasetConfiguration
|
This is on path to deprecation and will not be supported going forward.
|
|
ExportDefinition
|
The definition of an export.
|
|
ExportDeliveryDestination
|
This represents the blob storage account location where exports of costs will be delivered. There are two ways to configure the destination. The approach recommended for most customers is to specify the resourceId of the storage account. This requires a one-time registration of the account's subscription with the Microsoft.CostManagementExports resource provider in order to give Cost Management services access to the storage. When creating an export in the Azure portal this registration is performed automatically but API users may need to register the subscription explicitly (for more information see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services ). Another way to configure the destination is available ONLY to Partners with a Microsoft Partner Agreement plan who are global admins of their billing account. These Partners, instead of specifying the resourceId of a storage account, can specify the storage account name along with a SAS token for the account. This allows exports of costs to a storage account in any tenant. The SAS token should be created for the blob service with Service/Container/Object resource types and with Read/Write/Delete/List/Add/Create permissions (for more information see https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/export-cost-data-storage-account-sas-key ).
|
|
ExportDeliveryInfo
|
The delivery information associated with a export.
|
|
ExportExecutionListResult
|
Result of listing the run history of an export.
|
|
ExportRecurrencePeriod
|
The start and end date for recurrence schedule.
|
|
ExportRun
|
An export run.
|
|
ExportSchedule
|
The schedule associated with the export.
|
|
ExportSuspensionContext
|
The properties of the export run. This is not populated currently.
|
|
ExportTimePeriod
|
The date range for data in the export. This should only be specified with timeFrame set to 'Custom'. The maximum date range is 1 calendar month.
|
|
ExportType
|
The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations.
|
|
FilterItemNames
|
The name of the filter. This is currently only supported for Export Definition type of ReservationRecommendations. Supported names are ['ReservationScope', 'LookBackPeriod', 'ResourceType']
|
|
FilterItems
|
Will contain the filter name and value to operate on. This is currently only supported for Export Definition type of ReservationRecommendations.
|
|
FormatType
|
The format of the export being delivered.
|
|
GranularityType
|
The granularity of rows in the export. Currently 'Daily' is supported for most cases.
|
|
RecurrenceType
|
The schedule recurrence.
|
|
StatusType
|
The status of the export's schedule. If 'Inactive', the export's schedule is paused. To enable export set the status to be Active and then make a PUT request.
|
|
SystemAssignedServiceIdentity
|
Managed service identity (either system assigned, or none)
|
|
SystemAssignedServiceIdentityType
|
Type of managed service identity (either system assigned, or none).
|
|
systemData
|
Metadata pertaining to creation and last modification of the resource.
|
|
TimeframeType
|
The time frame for pulling data for the export. If custom, then a specific time period must be provided.
|
CommonExportProperties
Object
The common properties of the export.
| Name |
Type |
Description |
|
compressionMode
|
CompressionModeType
|
Allow customers to select compress data for exports. This setting will enable destination file compression scheme at runtime. By default set to None. Gzip is for csv and snappy for parquet.
|
|
dataOverwriteBehavior
|
DataOverwriteBehaviorType
|
Allow customers to select overwrite data(OverwritePreviousReport) for exports. This setting will enable overwrite data for the same month in customer storage account. By default set to CreateNewReport.
|
|
definition
|
ExportDefinition
|
Has the definition for the export.
|
|
deliveryInfo
|
ExportDeliveryInfo
|
Has delivery information for the export.
|
|
exportDescription
|
string
|
The export description set by customer at time of export creation/update.
|
|
format
|
FormatType
|
The format of the export being delivered.
|
|
nextRunTimeEstimate
|
string
(date-time)
|
If the export has an active schedule, provides an estimate of the next run time.
|
|
partitionData
|
boolean
|
If set to true, exported data will be partitioned by size and placed in a blob directory together with a manifest file.
|
|
runHistory
|
ExportExecutionListResult
|
If requested, has the most recent run history for the export.
|
|
systemSuspensionContext
|
ExportSuspensionContext
|
The export suspension reason if export is in SystemSuspended state. This is not populated currently.
|
CompressionModeType
Enumeration
Allow customers to select compress data for exports. This setting will enable destination file compression scheme at runtime. By default set to None. Gzip is for csv and snappy for parquet.
| Value |
Description |
|
gzip
|
|
|
snappy
|
|
|
none
|
|
createdByType
Enumeration
The type of identity that created the resource.
| Value |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
DataOverwriteBehaviorType
Enumeration
Allow customers to select overwrite data(OverwritePreviousReport) for exports. This setting will enable overwrite data for the same month in customer storage account. By default set to CreateNewReport.
| Value |
Description |
|
OverwritePreviousReport
|
|
|
CreateNewReport
|
|
DestinationType
Enumeration
The export delivery destination type. Currently only 'AzureBlob' is supported.
| Value |
Description |
|
AzureBlob
|
|
ErrorDetails
Object
The details of the error.
| Name |
Type |
Description |
|
code
|
string
|
Error code.
|
|
message
|
string
|
Error message indicating why the operation failed.
|
ErrorResponse
Object
Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. \n\nSome Error responses: \n\n * 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "x-ms-ratelimit-microsoft.consumption-retry-after" header. \n\n * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" header.
| Name |
Type |
Description |
|
error
|
ErrorDetails
|
The details of the error.
|
ExecutionStatus
Enumeration
The last known status of the export run.
| Value |
Description |
|
Queued
|
|
|
InProgress
|
|
|
Completed
|
|
|
Failed
|
|
|
Timeout
|
|
|
NewDataNotAvailable
|
|
|
DataNotAvailable
|
|
ExecutionType
Enumeration
The type of the export run.
| Value |
Description |
|
OnDemand
|
|
|
Scheduled
|
|
Export
Object
An export resource.
| Name |
Type |
Description |
|
eTag
|
string
|
eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.
|
|
id
|
string
(arm-id)
|
Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
identity
|
SystemAssignedServiceIdentity
|
The managed identity associated with Export
|
|
location
|
string
|
The location of the Export's managed identity. Only required when utilizing managed identity.
|
|
name
|
string
|
The name of the resource
|
|
properties.compressionMode
|
CompressionModeType
|
Allow customers to select compress data for exports. This setting will enable destination file compression scheme at runtime. By default set to None. Gzip is for csv and snappy for parquet.
|
|
properties.dataOverwriteBehavior
|
DataOverwriteBehaviorType
|
Allow customers to select overwrite data(OverwritePreviousReport) for exports. This setting will enable overwrite data for the same month in customer storage account. By default set to CreateNewReport.
|
|
properties.definition
|
ExportDefinition
|
Has the definition for the export.
|
|
properties.deliveryInfo
|
ExportDeliveryInfo
|
Has delivery information for the export.
|
|
properties.exportDescription
|
string
|
The export description set by customer at time of export creation/update.
|
|
properties.format
|
FormatType
|
The format of the export being delivered.
|
|
properties.nextRunTimeEstimate
|
string
(date-time)
|
If the export has an active schedule, provides an estimate of the next run time.
|
|
properties.partitionData
|
boolean
|
If set to true, exported data will be partitioned by size and placed in a blob directory together with a manifest file.
|
|
properties.runHistory
|
ExportExecutionListResult
|
If requested, has the most recent run history for the export.
|
|
properties.schedule
|
ExportSchedule
|
Has schedule information for the export.
|
|
properties.systemSuspensionContext
|
ExportSuspensionContext
|
The export suspension reason if export is in SystemSuspended state. This is not populated currently.
|
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
ExportDataset
Object
The definition for data in the export.
| Name |
Type |
Description |
|
configuration
|
ExportDatasetConfiguration
|
The export dataset configuration.
|
|
granularity
|
GranularityType
|
The granularity of rows in the export. Currently 'Daily' is supported for most cases.
|
ExportDatasetConfiguration
Object
This is on path to deprecation and will not be supported going forward.
| Name |
Type |
Description |
|
columns
|
string[]
|
Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples).
|
|
dataVersion
|
string
|
The data version for the selected for the export. If not provided then the export will default to latest data version.
|
|
filters
|
FilterItems[]
|
Filters associated with the data sets.
|
ExportDefinition
Object
The definition of an export.
| Name |
Type |
Description |
|
dataSet
|
ExportDataset
|
The definition for data in the export.
|
|
timePeriod
|
ExportTimePeriod
|
Has time period for pulling data for the export.
|
|
timeframe
|
TimeframeType
|
The time frame for pulling data for the export. If custom, then a specific time period must be provided.
|
|
type
|
ExportType
|
The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations.
|
ExportDeliveryDestination
Object
This represents the blob storage account location where exports of costs will be delivered. There are two ways to configure the destination. The approach recommended for most customers is to specify the resourceId of the storage account. This requires a one-time registration of the account's subscription with the Microsoft.CostManagementExports resource provider in order to give Cost Management services access to the storage. When creating an export in the Azure portal this registration is performed automatically but API users may need to register the subscription explicitly (for more information see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services ). Another way to configure the destination is available ONLY to Partners with a Microsoft Partner Agreement plan who are global admins of their billing account. These Partners, instead of specifying the resourceId of a storage account, can specify the storage account name along with a SAS token for the account. This allows exports of costs to a storage account in any tenant. The SAS token should be created for the blob service with Service/Container/Object resource types and with Read/Write/Delete/List/Add/Create permissions (for more information see https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/export-cost-data-storage-account-sas-key ).
| Name |
Type |
Description |
|
container
|
string
|
The name of the container where exports will be uploaded. If the container does not exist it will be created.
|
|
resourceId
|
string
|
The resource id of the storage account where exports will be delivered. This is not required if a sasToken and storageAccount are specified.
|
|
rootFolderPath
|
string
|
The name of the directory where exports will be uploaded.
|
|
sasToken
|
string
(password)
|
A SAS token for the storage account. For a restricted set of Azure customers this together with storageAccount can be specified instead of resourceId. Note: the value returned by the API for this property will always be obfuscated. Returning this same obfuscated value will not result in the SAS token being updated. To update this value a new SAS token must be specified.
|
|
storageAccount
|
string
|
The storage account where exports will be uploaded. For a restricted set of Azure customers this together with sasToken can be specified instead of resourceId.
|
|
type
|
DestinationType
|
The export delivery destination type. Currently only 'AzureBlob' is supported.
|
ExportDeliveryInfo
Object
The delivery information associated with a export.
ExportExecutionListResult
Object
Result of listing the run history of an export.
| Name |
Type |
Description |
|
value
|
ExportRun[]
|
A list of export runs.
|
ExportRecurrencePeriod
Object
The start and end date for recurrence schedule.
| Name |
Type |
Description |
|
from
|
string
(date-time)
|
The start date of recurrence.
|
|
to
|
string
(date-time)
|
The end date of recurrence.
|
ExportRun
Object
An export run.
| Name |
Type |
Description |
|
eTag
|
string
|
eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not.
|
|
id
|
string
|
Resource Id.
|
|
name
|
string
|
Resource name.
|
|
properties.endDate
|
string
(date-time)
|
The end datetime for the export.
|
|
properties.error
|
ErrorDetails
|
The details of any error.
|
|
properties.executionType
|
ExecutionType
|
The type of the export run.
|
|
properties.fileName
|
string
|
The name of the exported file.
|
|
properties.manifestFile
|
string
|
The manifest file location(URI location) for the exported files.
|
|
properties.processingEndTime
|
string
(date-time)
|
The time when the export run finished.
|
|
properties.processingStartTime
|
string
(date-time)
|
The time when export was picked up to be run.
|
|
properties.runSettings
|
CommonExportProperties
|
The export settings that were in effect for this run.
|
|
properties.startDate
|
string
(date-time)
|
The start datetime for the export.
|
|
properties.status
|
ExecutionStatus
|
The last known status of the export run.
|
|
properties.submittedBy
|
string
|
The identifier for the entity that triggered the export. For on-demand runs it is the user email. For scheduled runs it is 'System'.
|
|
properties.submittedTime
|
string
(date-time)
|
The time when export was queued to be run.
|
|
type
|
string
|
Resource type.
|
ExportSchedule
Object
The schedule associated with the export.
| Name |
Type |
Description |
|
recurrence
|
RecurrenceType
|
The schedule recurrence.
|
|
recurrencePeriod
|
ExportRecurrencePeriod
|
Has start and end date of the recurrence. The start date must be in future. If present, the end date must be greater than start date.
|
|
status
|
StatusType
|
The status of the export's schedule. If 'Inactive', the export's schedule is paused. To enable export set the status to be Active and then make a PUT request.
|
ExportSuspensionContext
Object
The properties of the export run. This is not populated currently.
| Name |
Type |
Description |
|
suspensionCode
|
string
|
The code for export suspension.
|
|
suspensionReason
|
string
|
The detailed reason for export suspension.
|
|
suspensionTime
|
string
(date-time)
|
The time when the export was suspended.
|
ExportTimePeriod
Object
The date range for data in the export. This should only be specified with timeFrame set to 'Custom'. The maximum date range is 1 calendar month.
| Name |
Type |
Description |
|
from
|
string
(date-time)
|
The start date for export data.
|
|
to
|
string
(date-time)
|
The end date for export data.
|
ExportType
Enumeration
The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that do not yet provide data for charges or amortization for service reservations.
| Value |
Description |
|
Usage
|
|
|
ActualCost
|
|
|
AmortizedCost
|
|
|
FocusCost
|
|
|
PriceSheet
|
|
|
ReservationTransactions
|
|
|
ReservationRecommendations
|
|
|
ReservationDetails
|
|
FilterItemNames
Enumeration
The name of the filter. This is currently only supported for Export Definition type of ReservationRecommendations. Supported names are ['ReservationScope', 'LookBackPeriod', 'ResourceType']
| Value |
Description |
|
ReservationScope
|
|
|
ResourceType
|
|
|
LookBackPeriod
|
|
FilterItems
Object
Will contain the filter name and value to operate on. This is currently only supported for Export Definition type of ReservationRecommendations.
| Name |
Type |
Description |
|
name
|
FilterItemNames
|
The name of the filter. This is currently only supported for Export Definition type of ReservationRecommendations. Supported names are ['ReservationScope', 'LookBackPeriod', 'ResourceType']
|
|
value
|
string
|
Value to filter by. Currently values supported per name are, for 'ReservationScope' supported values are ['Single', 'Shared'], for 'LookBackPeriod' supported values are ['Last7Days', 'Last30Days', 'Last60Days'] and for 'ResourceType' supported values are ['VirtualMachines', 'SQLDatabases', 'PostgreSQL', 'ManagedDisk', 'MySQL', 'RedHat', 'MariaDB', 'RedisCache', 'CosmosDB', 'SqlDataWarehouse', 'SUSELinux', 'AppService', 'BlockBlob', 'AzureDataExplorer', 'VMwareCloudSimple'].
|
Enumeration
The format of the export being delivered.
| Value |
Description |
|
Csv
|
|
|
Parquet
|
|
GranularityType
Enumeration
The granularity of rows in the export. Currently 'Daily' is supported for most cases.
| Value |
Description |
|
Daily
|
|
|
Monthly
|
|
RecurrenceType
Enumeration
The schedule recurrence.
| Value |
Description |
|
Daily
|
|
|
Weekly
|
|
|
Monthly
|
|
|
Annually
|
|
StatusType
Enumeration
The status of the export's schedule. If 'Inactive', the export's schedule is paused. To enable export set the status to be Active and then make a PUT request.
| Value |
Description |
|
Active
|
|
|
Inactive
|
|
SystemAssignedServiceIdentity
Object
Managed service identity (either system assigned, or none)
| Name |
Type |
Description |
|
principalId
|
string
(uuid)
|
The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity.
|
|
tenantId
|
string
(uuid)
|
The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity.
|
|
type
|
SystemAssignedServiceIdentityType
|
Type of managed service identity (either system assigned, or none).
|
SystemAssignedServiceIdentityType
Enumeration
Type of managed service identity (either system assigned, or none).
| Value |
Description |
|
None
|
|
|
SystemAssigned
|
|
systemData
Object
Metadata pertaining to creation and last modification of the resource.
| Name |
Type |
Description |
|
createdAt
|
string
(date-time)
|
The timestamp of resource creation (UTC).
|
|
createdBy
|
string
|
The identity that created the resource.
|
|
createdByType
|
createdByType
|
The type of identity that created the resource.
|
|
lastModifiedAt
|
string
(date-time)
|
The timestamp of resource last modification (UTC)
|
|
lastModifiedBy
|
string
|
The identity that last modified the resource.
|
|
lastModifiedByType
|
createdByType
|
The type of identity that last modified the resource.
|
TimeframeType
Enumeration
The time frame for pulling data for the export. If custom, then a specific time period must be provided.
| Value |
Description |
|
MonthToDate
|
|
|
BillingMonthToDate
|
|
|
TheLastMonth
|
|
|
TheLastBillingMonth
|
|
|
WeekToDate
|
|
|
Custom
|
|
|
TheCurrentMonth
|
|