0
# Storage Task Management
1
2
Storage task assignments for automated data processing and reporting on task execution. Storage tasks enable automated data transformation, processing, and management operations on storage account data.
3
4
## Capabilities
5
6
### Storage Task Assignment Management
7
8
Create and manage storage task assignments that define automated processing operations on storage data.
9
10
```python { .api }
11
class StorageTaskAssignmentsOperations:
12
def create(
13
self,
14
resource_group_name: str,
15
account_name: str,
16
storage_task_assignment_name: str,
17
parameters: StorageTaskAssignment
18
) -> StorageTaskAssignment:
19
"""
20
Creates a new storage task assignment.
21
22
Parameters:
23
- resource_group_name: Name of the resource group
24
- account_name: Name of the storage account
25
- storage_task_assignment_name: Name of the storage task assignment
26
- parameters: Storage task assignment configuration
27
28
Returns:
29
Created StorageTaskAssignment
30
"""
31
32
def get(
33
self,
34
resource_group_name: str,
35
account_name: str,
36
storage_task_assignment_name: str
37
) -> StorageTaskAssignment:
38
"""
39
Gets properties of a specified storage task assignment.
40
41
Parameters:
42
- resource_group_name: Name of the resource group
43
- account_name: Name of the storage account
44
- storage_task_assignment_name: Name of the storage task assignment
45
46
Returns:
47
StorageTaskAssignment with current configuration
48
"""
49
50
def delete(
51
self,
52
resource_group_name: str,
53
account_name: str,
54
storage_task_assignment_name: str
55
) -> None:
56
"""
57
Deletes a storage task assignment.
58
59
Parameters:
60
- resource_group_name: Name of the resource group
61
- account_name: Name of the storage account
62
- storage_task_assignment_name: Name of the storage task assignment
63
"""
64
65
def list(
66
self,
67
resource_group_name: str,
68
account_name: str,
69
maxpagesize: Optional[int] = None
70
) -> ItemPaged[StorageTaskAssignment]:
71
"""
72
Lists all storage task assignments in a storage account.
73
74
Parameters:
75
- resource_group_name: Name of the resource group
76
- account_name: Name of the storage account
77
- maxpagesize: Maximum number of results per page
78
79
Returns:
80
Paginated list of StorageTaskAssignment objects
81
"""
82
83
def update(
84
self,
85
resource_group_name: str,
86
account_name: str,
87
storage_task_assignment_name: str,
88
parameters: StorageTaskAssignmentUpdateParameters
89
) -> StorageTaskAssignment:
90
"""
91
Updates properties of a storage task assignment.
92
93
Parameters:
94
- resource_group_name: Name of the resource group
95
- account_name: Name of the storage account
96
- storage_task_assignment_name: Name of the storage task assignment
97
- parameters: Updated storage task assignment properties
98
99
Returns:
100
Updated StorageTaskAssignment
101
"""
102
```
103
104
Usage example:
105
106
```python
107
from azure.mgmt.storage.models import (
108
StorageTaskAssignment, StorageTaskAssignmentProperties,
109
ExecutionTrigger, TriggerParameters, ExecutionTarget
110
)
111
112
# Create a storage task assignment for data processing
113
execution_trigger = ExecutionTrigger(
114
type_=TriggerType.ON_SCHEDULE,
115
parameters=TriggerParameters(
116
start_on="2024-01-01T00:00:00Z",
117
interval=24, # Run daily
118
interval_unit="hours"
119
)
120
)
121
122
execution_target = ExecutionTarget(
123
prefix="data-processing/",
124
exclude_prefix=["temp/", "logs/"]
125
)
126
127
task_assignment = StorageTaskAssignment(
128
properties=StorageTaskAssignmentProperties(
129
task_id="/subscriptions/sub-id/resourceGroups/tasks-rg/providers/Microsoft.StorageActions/storageTasks/data-processor",
130
enabled=True,
131
description="Daily data processing and transformation task",
132
execution_context=StorageTaskAssignmentExecutionContext(
133
trigger=execution_trigger,
134
target=execution_target
135
),
136
report=StorageTaskAssignmentReport(
137
prefix="reports/task-reports/"
138
)
139
)
140
)
141
142
created_assignment = client.storage_task_assignments.create(
143
resource_group_name="my-resource-group",
144
account_name="mystorageaccount123",
145
storage_task_assignment_name="daily-data-processing",
146
parameters=task_assignment
147
)
148
149
print(f"Created task assignment: {created_assignment.name}")
150
151
# Create a cleanup task assignment
152
cleanup_trigger = ExecutionTrigger(
153
type_=TriggerType.ON_SCHEDULE,
154
parameters=TriggerParameters(
155
start_on="2024-01-01T02:00:00Z",
156
interval=168, # Run weekly (7 days * 24 hours)
157
interval_unit="hours"
158
)
159
)
160
161
cleanup_target = ExecutionTarget(
162
prefix="temp/",
163
exclude_prefix=["temp/important/"]
164
)
165
166
cleanup_assignment = StorageTaskAssignment(
167
properties=StorageTaskAssignmentProperties(
168
task_id="/subscriptions/sub-id/resourceGroups/tasks-rg/providers/Microsoft.StorageActions/storageTasks/cleanup-task",
169
enabled=True,
170
description="Weekly cleanup of temporary files",
171
execution_context=StorageTaskAssignmentExecutionContext(
172
trigger=cleanup_trigger,
173
target=cleanup_target
174
),
175
report=StorageTaskAssignmentReport(
176
prefix="reports/cleanup-reports/"
177
)
178
)
179
)
180
181
client.storage_task_assignments.create(
182
resource_group_name="my-resource-group",
183
account_name="mystorageaccount123",
184
storage_task_assignment_name="weekly-cleanup",
185
parameters=cleanup_assignment
186
)
187
188
# List all task assignments
189
assignments = list(client.storage_task_assignments.list(
190
resource_group_name="my-resource-group",
191
account_name="mystorageaccount123"
192
))
193
194
print(f"Total task assignments: {len(assignments)}")
195
for assignment in assignments:
196
print(f"Assignment: {assignment.name}")
197
print(f" Enabled: {assignment.properties.enabled}")
198
print(f" Description: {assignment.properties.description}")
199
print(f" Task ID: {assignment.properties.task_id}")
200
201
# Update task assignment
202
from azure.mgmt.storage.models import (
203
StorageTaskAssignmentUpdateParameters, StorageTaskAssignmentUpdateProperties,
204
StorageTaskAssignmentUpdateExecutionContext, ExecutionTriggerUpdate,
205
TriggerParametersUpdate
206
)
207
208
updated_trigger = ExecutionTriggerUpdate(
209
type_=TriggerType.ON_SCHEDULE,
210
parameters=TriggerParametersUpdate(
211
interval=12, # Change to every 12 hours
212
interval_unit="hours"
213
)
214
)
215
216
update_params = StorageTaskAssignmentUpdateParameters(
217
properties=StorageTaskAssignmentUpdateProperties(
218
enabled=True,
219
description="Updated: Semi-daily data processing task",
220
execution_context=StorageTaskAssignmentUpdateExecutionContext(
221
trigger=updated_trigger
222
)
223
)
224
)
225
226
updated_assignment = client.storage_task_assignments.update(
227
resource_group_name="my-resource-group",
228
account_name="mystorageaccount123",
229
storage_task_assignment_name="daily-data-processing",
230
parameters=update_params
231
)
232
233
print(f"Updated task assignment: {updated_assignment.name}")
234
```
235
236
### Storage Task Execution Reporting
237
238
Monitor and retrieve reports on storage task assignment execution.
239
240
```python { .api }
241
class StorageTaskAssignmentsInstancesReportOperations:
242
def list(
243
self,
244
resource_group_name: str,
245
account_name: str,
246
storage_task_assignment_name: str,
247
maxpagesize: Optional[int] = None,
248
filter: Optional[str] = None
249
) -> ItemPaged[StorageTaskReportInstance]:
250
"""
251
Lists execution instances of a storage task assignment.
252
253
Parameters:
254
- resource_group_name: Name of the resource group
255
- account_name: Name of the storage account
256
- storage_task_assignment_name: Name of the storage task assignment
257
- maxpagesize: Maximum number of results per page
258
- filter: OData filter expression
259
260
Returns:
261
Paginated list of StorageTaskReportInstance objects
262
"""
263
264
class StorageTaskAssignmentInstancesReportOperations:
265
def list(
266
self,
267
resource_group_name: str,
268
account_name: str,
269
storage_task_assignment_name: str,
270
maxpagesize: Optional[int] = None,
271
filter: Optional[str] = None
272
) -> ItemPaged[StorageTaskReportInstance]:
273
"""
274
Lists task assignment instance reports.
275
276
Parameters:
277
- resource_group_name: Name of the resource group
278
- account_name: Name of the storage account
279
- storage_task_assignment_name: Name of the storage task assignment
280
- maxpagesize: Maximum number of results per page
281
- filter: OData filter expression
282
283
Returns:
284
Paginated list of StorageTaskReportInstance objects
285
"""
286
```
287
288
Usage example:
289
290
```python
291
# List execution reports for a task assignment
292
execution_reports = list(client.storage_task_assignments_instances_report.list(
293
resource_group_name="my-resource-group",
294
account_name="mystorageaccount123",
295
storage_task_assignment_name="daily-data-processing",
296
maxpagesize=50
297
))
298
299
print(f"Found {len(execution_reports)} execution reports")
300
301
for report in execution_reports:
302
print(f"Execution ID: {report.properties.task_assignment_id}")
303
print(f" Start Time: {report.properties.start_time}")
304
print(f" Finish Time: {report.properties.finish_time}")
305
print(f" Status: {report.properties.run_status_enum}")
306
print(f" Run Result: {report.properties.run_result}")
307
308
if hasattr(report.properties, 'summary') and report.properties.summary:
309
summary = report.properties.summary
310
print(f" Objects Processed: {summary.objects_operated_on_count}")
311
print(f" Objects Failed: {summary.objects_failed_count}")
312
print(f" Objects Succeeded: {summary.objects_succeeded_count}")
313
print(f" Total Bytes Processed: {summary.total_objects_size_in_bytes}")
314
print()
315
316
# Filter reports by date range
317
from datetime import datetime, timedelta
318
319
last_week = (datetime.utcnow() - timedelta(days=7)).isoformat() + "Z"
320
filter_expression = f"properties/startTime ge '{last_week}'"
321
322
recent_reports = list(client.storage_task_assignment_instances_report.list(
323
resource_group_name="my-resource-group",
324
account_name="mystorageaccount123",
325
storage_task_assignment_name="daily-data-processing",
326
filter=filter_expression
327
))
328
329
print(f"Reports from last week: {len(recent_reports)}")
330
331
# Get reports for all task assignments
332
all_assignments = list(client.storage_task_assignments.list(
333
resource_group_name="my-resource-group",
334
account_name="mystorageaccount123"
335
))
336
337
for assignment in all_assignments:
338
reports = list(client.storage_task_assignments_instances_report.list(
339
resource_group_name="my-resource-group",
340
account_name="mystorageaccount123",
341
storage_task_assignment_name=assignment.name,
342
maxpagesize=10 # Get last 10 reports
343
))
344
345
print(f"Task: {assignment.name} - {len(reports)} recent reports")
346
347
# Calculate success rate
348
if reports:
349
successful = len([r for r in reports if r.properties.run_result == RunResult.SUCCEEDED])
350
success_rate = (successful / len(reports)) * 100
351
print(f" Success Rate: {success_rate:.1f}%")
352
```
353
354
## Types
355
356
```python { .api }
357
class StorageTaskAssignment:
358
"""Storage task assignment resource."""
359
id: str
360
name: str
361
type_: str
362
properties: StorageTaskAssignmentProperties
363
364
class StorageTaskAssignmentProperties:
365
"""Properties of storage task assignment."""
366
task_id: str
367
enabled: bool
368
description: str
369
execution_context: StorageTaskAssignmentExecutionContext
370
report: StorageTaskAssignmentReport
371
provisioning_state: ProvisioningState
372
373
class StorageTaskAssignmentExecutionContext:
374
"""Execution context for storage task assignment."""
375
trigger: ExecutionTrigger
376
target: ExecutionTarget
377
378
class ExecutionTrigger:
379
"""Trigger configuration for task execution."""
380
type_: TriggerType
381
parameters: TriggerParameters
382
383
class TriggerParameters:
384
"""Parameters for execution trigger."""
385
start_on: str
386
interval: int
387
interval_unit: str
388
end_on: str
389
390
class ExecutionTarget:
391
"""Target configuration for task execution."""
392
prefix: str
393
exclude_prefix: List[str]
394
395
class StorageTaskAssignmentReport:
396
"""Report configuration for task assignment."""
397
prefix: str
398
399
class StorageTaskReportInstance:
400
"""Individual task execution report."""
401
id: str
402
name: str
403
type_: str
404
properties: StorageTaskReportProperties
405
406
class StorageTaskReportProperties:
407
"""Properties of task execution report."""
408
task_assignment_id: str
409
storage_account_id: str
410
start_time: str
411
finish_time: str
412
object_target_count: str
413
objects_operated_on_count: str
414
objects_succeeded_count: str
415
objects_failed_count: str
416
run_status_enum: RunStatusEnum
417
run_result: RunResult
418
summary_report_path: str
419
task_id: str
420
task_version: str
421
422
class StorageTaskReportSummary:
423
"""Summary of task execution results."""
424
objects_count: str
425
objects_operated_on_count: str
426
objects_succeeded_count: str
427
objects_failed_count: str
428
total_objects_size_in_bytes: str
429
430
class StorageTaskAssignmentUpdateParameters:
431
"""Parameters for updating storage task assignment."""
432
properties: StorageTaskAssignmentUpdateProperties
433
434
class StorageTaskAssignmentUpdateProperties:
435
"""Updated properties for storage task assignment."""
436
enabled: bool
437
description: str
438
execution_context: StorageTaskAssignmentUpdateExecutionContext
439
report: StorageTaskAssignmentUpdateReport
440
441
class TriggerType(str, Enum):
442
"""Types of execution triggers."""
443
ON_SCHEDULE = "OnSchedule"
444
RUN_ONCE = "RunOnce"
445
446
class RunStatusEnum(str, Enum):
447
"""Status of task execution."""
448
IN_PROGRESS = "InProgress"
449
COMPLETED = "Completed"
450
FAILED = "Failed"
451
452
class RunResult(str, Enum):
453
"""Result of task execution."""
454
SUCCEEDED = "Succeeded"
455
FAILED = "Failed"
456
```