0
# Data Export Operations
1
2
Schedule and manage automated data exports for cost and usage data. Configure recurring exports to Azure storage accounts with custom formats, delivery schedules, and comprehensive cost data for analysis and integration with external systems.
3
4
## Capabilities
5
6
### Export Management
7
8
Create, update, and manage cost data export configurations with flexible scheduling and delivery options.
9
10
```python { .api }
11
def list(scope: str, expand: str = None) -> ExportListResult:
12
"""
13
List all exports for the specified scope.
14
15
Args:
16
scope (str): The scope to list exports for
17
expand (str): Expand options for additional properties
18
19
Returns:
20
ExportListResult: Collection of export configurations
21
"""
22
23
def get(scope: str, export_name: str, expand: str = None) -> Export:
24
"""
25
Get a specific export configuration by name.
26
27
Args:
28
scope (str): The scope containing the export
29
export_name (str): Name of the export configuration
30
expand (str): Expand options for additional properties
31
32
Returns:
33
Export: Export configuration details
34
"""
35
36
def create_or_update(scope: str, export_name: str, parameters: Export) -> Export:
37
"""
38
Create or update an export configuration.
39
40
Args:
41
scope (str): The scope for the export
42
export_name (str): Name for the export configuration
43
parameters (Export): Export configuration details
44
45
Returns:
46
Export: Created or updated export configuration
47
"""
48
49
def delete(scope: str, export_name: str) -> None:
50
"""
51
Delete an export configuration.
52
53
Args:
54
scope (str): The scope containing the export
55
export_name (str): Name of the export to delete
56
"""
57
```
58
59
### Export Execution
60
61
Execute exports immediately and track execution history for monitoring and troubleshooting.
62
63
```python { .api }
64
def execute(scope: str, export_name: str) -> ExportRun:
65
"""
66
Execute an export immediately.
67
68
Args:
69
scope (str): The scope containing the export
70
export_name (str): Name of the export to execute
71
72
Returns:
73
ExportRun: Execution details and status
74
"""
75
76
def get_execution_history(scope: str, export_name: str) -> ExportExecutionListResult:
77
"""
78
Get execution history for an export.
79
80
Args:
81
scope (str): The scope containing the export
82
export_name (str): Name of the export
83
84
Returns:
85
ExportExecutionListResult: List of export execution records
86
"""
87
```
88
89
## Usage Examples
90
91
### Create Daily Cost Export
92
93
```python
94
from azure.mgmt.costmanagement.models import (
95
Export,
96
ExportDefinition,
97
ExportDeliveryInfo,
98
ExportDeliveryDestination,
99
ExportSchedule,
100
ExportRecurrencePeriod,
101
ExportDataset,
102
ExportTimePeriod,
103
RecurrenceType,
104
FormatType,
105
TimeframeType,
106
GranularityType
107
)
108
109
# Configure export destination (Azure Storage)
110
delivery_destination = ExportDeliveryDestination(
111
resource_id="/subscriptions/{sub-id}/resourceGroups/{rg}/providers/Microsoft.Storage/storageAccounts/{storage}",
112
container="cost-exports",
113
root_folder_path="daily-costs"
114
)
115
116
delivery_info = ExportDeliveryInfo(destination=delivery_destination)
117
118
# Configure export schedule (daily)
119
recurrence_period = ExportRecurrencePeriod(
120
from_property="2024-01-01T00:00:00Z",
121
to="2024-12-31T23:59:59Z"
122
)
123
124
schedule = ExportSchedule(
125
status="Active",
126
recurrence=RecurrenceType.DAILY,
127
recurrence_period=recurrence_period
128
)
129
130
# Configure export dataset
131
dataset = ExportDataset(
132
granularity=GranularityType.DAILY
133
)
134
135
# Configure export definition
136
export_definition = ExportDefinition(
137
type="ActualCost",
138
timeframe=TimeframeType.MONTH_TO_DATE,
139
dataset=dataset
140
)
141
142
# Create export
143
export_config = Export()
144
export_config.properties = ExportProperties(
145
format=FormatType.CSV,
146
delivery_info=delivery_info,
147
schedule=schedule,
148
definition=export_definition
149
)
150
151
scope = "/subscriptions/{subscription-id}"
152
created_export = client.exports.create_or_update(
153
scope=scope,
154
export_name="daily-cost-export",
155
parameters=export_config
156
)
157
158
print(f"Created export: {created_export.name}")
159
```
160
161
### List and Monitor Exports
162
163
```python
164
# List all exports for subscription
165
exports = client.exports.list(scope)
166
167
print(f"Found {len(exports.value)} exports:")
168
for export in exports.value:
169
props = export.properties
170
print(f" Name: {export.name}")
171
print(f" Type: {props.definition.type}")
172
print(f" Schedule: {props.schedule.recurrence}")
173
print(f" Status: {props.schedule.status}")
174
print(f" Next Run: {props.next_run_time_estimate}")
175
print(" ---")
176
```
177
178
### Execute Export Immediately
179
180
```python
181
# Execute an export on-demand
182
export_run = client.exports.execute(scope, "daily-cost-export")
183
184
print(f"Export execution started:")
185
print(f" Status: {export_run.properties.status}")
186
print(f" Execution Type: {export_run.properties.execution_type}")
187
print(f" Run Settings: {export_run.properties.run_settings}")
188
```
189
190
### Monitor Export Execution History
191
192
```python
193
# Get execution history
194
execution_history = client.exports.get_execution_history(scope, "daily-cost-export")
195
196
print(f"Export execution history ({len(execution_history.value)} runs):")
197
for run in execution_history.value:
198
props = run.properties
199
print(f" Run Time: {props.execution_time}")
200
print(f" Status: {props.status}")
201
print(f" Processing Start: {props.processing_start_time}")
202
print(f" Processing End: {props.processing_end_time}")
203
if props.file_name:
204
print(f" File: {props.file_name}")
205
if props.error:
206
print(f" Error: {props.error}")
207
print(" ---")
208
```
209
210
### Create Monthly Amortized Cost Export
211
212
```python
213
# Monthly export with amortized costs
214
monthly_dataset = ExportDataset(
215
granularity=GranularityType.MONTHLY
216
)
217
218
monthly_schedule = ExportSchedule(
219
status="Active",
220
recurrence=RecurrenceType.MONTHLY,
221
recurrence_period=ExportRecurrencePeriod(
222
from_property="2024-01-01T00:00:00Z"
223
)
224
)
225
226
monthly_export_def = ExportDefinition(
227
type="AmortizedCost",
228
timeframe=TimeframeType.THE_LAST_MONTH,
229
dataset=monthly_dataset
230
)
231
232
monthly_export = Export()
233
monthly_export.properties = ExportProperties(
234
format=FormatType.CSV,
235
delivery_info=delivery_info,
236
schedule=monthly_schedule,
237
definition=monthly_export_def
238
)
239
240
monthly_created = client.exports.create_or_update(
241
scope=scope,
242
export_name="monthly-amortized-export",
243
parameters=monthly_export
244
)
245
```
246
247
## Data Models
248
249
### Export Configuration Models
250
251
```python { .api }
252
class Export:
253
id: str
254
name: str
255
type: str
256
properties: ExportProperties
257
258
class ExportProperties:
259
format: FormatType
260
delivery_info: ExportDeliveryInfo
261
definition: ExportDefinition
262
run_history: CommonExportProperties
263
next_run_time_estimate: str
264
schedule: ExportSchedule
265
266
class ExportDefinition:
267
type: str
268
timeframe: TimeframeType
269
time_period: ExportTimePeriod
270
dataset: ExportDataset
271
272
class ExportDataset:
273
granularity: GranularityType
274
configuration: ExportDatasetConfiguration
275
276
class ExportDeliveryInfo:
277
destination: ExportDeliveryDestination
278
279
class ExportDeliveryDestination:
280
resource_id: str
281
container: str
282
root_folder_path: str
283
284
class ExportSchedule:
285
status: str
286
recurrence: RecurrenceType
287
recurrence_period: ExportRecurrencePeriod
288
289
class ExportRecurrencePeriod:
290
from_property: str
291
to: str
292
```
293
294
### Export Execution Models
295
296
```python { .api }
297
class ExportRun:
298
id: str
299
name: str
300
type: str
301
properties: ExportRunProperties
302
303
class ExportRunProperties:
304
status: ExecutionStatus
305
error: ErrorDetails
306
execution_type: ExecutionType
307
file_name: str
308
processing_start_time: str
309
processing_end_time: str
310
execution_time: str
311
run_settings: CommonExportProperties
312
313
class ExportListResult:
314
value: List[Export]
315
316
class ExportExecutionListResult:
317
value: List[ExportRun]
318
319
class CommonExportProperties:
320
partition_data: bool
321
data_overwrite_behavior: str
322
```
323
324
## Export Enumerations
325
326
```python { .api }
327
class FormatType(str, Enum):
328
CSV = "Csv"
329
330
class RecurrenceType(str, Enum):
331
DAILY = "Daily"
332
WEEKLY = "Weekly"
333
MONTHLY = "Monthly"
334
ANNUALLY = "Annually"
335
336
class ExecutionStatus(str, Enum):
337
QUEUED = "Queued"
338
IN_PROGRESS = "InProgress"
339
COMPLETED = "Completed"
340
FAILED = "Failed"
341
TIMEOUT = "Timeout"
342
NEW_DATA_NOT_AVAILABLE = "NewDataNotAvailable"
343
DATA_NOT_AVAILABLE = "DataNotAvailable"
344
345
class ExecutionType(str, Enum):
346
ON_DEMAND = "OnDemand"
347
SCHEDULED = "Scheduled"
348
349
class ExportType(str, Enum):
350
USAGE = "Usage"
351
ACTUAL_COST = "ActualCost"
352
AMORTIZED_COST = "AmortizedCost"
353
```
354
355
This module provides comprehensive data export capabilities for automating cost data delivery to external storage systems for analysis, reporting, and integration workflows.