0
# Workflow Management
1
2
Logic Apps workflow management including workflow definitions, runs, triggers, actions, and integration with other Azure services.
3
4
## Package Information
5
6
- **Package**: azure-mgmt-web
7
- **Modules**: Multiple workflow-related operations classes
8
- **Access**: `client.workflows`, `client.workflow_runs`, `client.workflow_triggers`, etc.
9
10
## Core Imports
11
12
```python
13
from azure.mgmt.web import WebSiteManagementClient
14
from azure.mgmt.web.models import (
15
Workflow, WorkflowRun, WorkflowTrigger, WorkflowTriggerHistory,
16
WorkflowVersion, WorkflowRunAction
17
)
18
from azure.identity import DefaultAzureCredential
19
```
20
21
## Basic Usage
22
23
```python
24
from azure.mgmt.web import WebSiteManagementClient
25
from azure.identity import DefaultAzureCredential
26
27
credential = DefaultAzureCredential()
28
client = WebSiteManagementClient(credential, subscription_id)
29
30
# List workflows in a resource group
31
workflows = client.workflows.list(
32
resource_group_name="my-resource-group",
33
name="my-logic-app"
34
)
35
36
for workflow in workflows:
37
print(f"Workflow: {workflow.name}, State: {workflow.state}")
38
39
# Get workflow details
40
workflow_details = client.workflows.get(
41
resource_group_name="my-resource-group",
42
name="my-logic-app",
43
workflow_name="my-workflow"
44
)
45
```
46
47
## Workflow Operations
48
49
### Create or Update Workflow
50
51
Create a new workflow or update an existing one.
52
53
```python { .api }
54
def create_or_update(
55
self,
56
resource_group_name: str,
57
name: str,
58
workflow_name: str,
59
workflow: Workflow,
60
**kwargs
61
) -> Workflow:
62
"""
63
Create or update a workflow.
64
65
Args:
66
resource_group_name: Name of the resource group
67
name: Name of the logic app
68
workflow_name: Name of the workflow
69
workflow: Workflow definition
70
71
Returns:
72
Workflow object
73
"""
74
```
75
76
**Usage Example:**
77
78
```python
79
from azure.mgmt.web.models import Workflow
80
81
# Define workflow
82
workflow_definition = {
83
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
84
"contentVersion": "1.0.0.0",
85
"triggers": {
86
"manual": {
87
"type": "Request",
88
"kind": "Http",
89
"inputs": {
90
"schema": {}
91
}
92
}
93
},
94
"actions": {
95
"Response": {
96
"type": "Response",
97
"inputs": {
98
"statusCode": 200,
99
"body": "Hello World"
100
}
101
}
102
}
103
}
104
105
workflow = Workflow(
106
location="East US",
107
definition=workflow_definition,
108
state="Enabled"
109
)
110
111
created_workflow = client.workflows.create_or_update(
112
resource_group_name="my-resource-group",
113
name="my-logic-app",
114
workflow_name="my-workflow",
115
workflow=workflow
116
)
117
```
118
119
### Get Workflow
120
121
Retrieve details for a specific workflow.
122
123
```python { .api }
124
def get(
125
self,
126
resource_group_name: str,
127
name: str,
128
workflow_name: str,
129
**kwargs
130
) -> Workflow:
131
"""
132
Get workflow details.
133
134
Args:
135
resource_group_name: Name of the resource group
136
name: Name of the logic app
137
workflow_name: Name of the workflow
138
139
Returns:
140
Workflow object
141
"""
142
```
143
144
### List Workflows
145
146
Get all workflows in a logic app.
147
148
```python { .api }
149
def list(
150
self,
151
resource_group_name: str,
152
name: str,
153
**kwargs
154
) -> List[Workflow]:
155
"""
156
List workflows in the logic app.
157
158
Args:
159
resource_group_name: Name of the resource group
160
name: Name of the logic app
161
162
Returns:
163
List of Workflow objects
164
"""
165
```
166
167
### Delete Workflow
168
169
Remove a workflow from the logic app.
170
171
```python { .api }
172
def delete(
173
self,
174
resource_group_name: str,
175
name: str,
176
workflow_name: str,
177
**kwargs
178
) -> None:
179
"""
180
Delete a workflow.
181
182
Args:
183
resource_group_name: Name of the resource group
184
name: Name of the logic app
185
workflow_name: Name of the workflow
186
"""
187
```
188
189
## Workflow Run Management
190
191
### List Workflow Runs
192
193
Get all runs for a specific workflow.
194
195
```python { .api }
196
def list(
197
self,
198
resource_group_name: str,
199
name: str,
200
workflow_name: str,
201
**kwargs
202
) -> List[WorkflowRun]:
203
"""
204
List workflow runs.
205
206
Args:
207
resource_group_name: Name of the resource group
208
name: Name of the logic app
209
workflow_name: Name of the workflow
210
211
Returns:
212
List of WorkflowRun objects
213
"""
214
```
215
216
### Get Workflow Run
217
218
Retrieve details for a specific workflow run.
219
220
```python { .api }
221
def get(
222
self,
223
resource_group_name: str,
224
name: str,
225
workflow_name: str,
226
run_name: str,
227
**kwargs
228
) -> WorkflowRun:
229
"""
230
Get workflow run details.
231
232
Args:
233
resource_group_name: Name of the resource group
234
name: Name of the logic app
235
workflow_name: Name of the workflow
236
run_name: Name of the run
237
238
Returns:
239
WorkflowRun object
240
"""
241
```
242
243
### Cancel Workflow Run
244
245
Stop a running workflow execution.
246
247
```python { .api }
248
def cancel(
249
self,
250
resource_group_name: str,
251
name: str,
252
workflow_name: str,
253
run_name: str,
254
**kwargs
255
) -> None:
256
"""
257
Cancel a workflow run.
258
259
Args:
260
resource_group_name: Name of the resource group
261
name: Name of the logic app
262
workflow_name: Name of the workflow
263
run_name: Name of the run
264
"""
265
```
266
267
**Usage Example:**
268
269
```python
270
# List recent workflow runs
271
runs = client.workflow_runs.list(
272
resource_group_name="my-resource-group",
273
name="my-logic-app",
274
workflow_name="my-workflow"
275
)
276
277
for run in runs:
278
print(f"Run: {run.name}, Status: {run.status}, Start Time: {run.start_time}")
279
280
# Get specific run details
281
run_details = client.workflow_runs.get(
282
resource_group_name="my-resource-group",
283
name="my-logic-app",
284
workflow_name="my-workflow",
285
run_name="08586776228332053649"
286
)
287
288
# Cancel a running workflow
289
if run_details.status == "Running":
290
client.workflow_runs.cancel(
291
resource_group_name="my-resource-group",
292
name="my-logic-app",
293
workflow_name="my-workflow",
294
run_name=run_details.name
295
)
296
```
297
298
## Workflow Run Actions
299
300
### List Run Actions
301
302
Get all actions executed in a workflow run.
303
304
```python { .api }
305
def list(
306
self,
307
resource_group_name: str,
308
name: str,
309
workflow_name: str,
310
run_name: str,
311
**kwargs
312
) -> List[WorkflowRunAction]:
313
"""
314
List actions in a workflow run.
315
316
Args:
317
resource_group_name: Name of the resource group
318
name: Name of the logic app
319
workflow_name: Name of the workflow
320
run_name: Name of the run
321
322
Returns:
323
List of WorkflowRunAction objects
324
"""
325
```
326
327
### Get Run Action
328
329
Retrieve details for a specific action in a run.
330
331
```python { .api }
332
def get(
333
self,
334
resource_group_name: str,
335
name: str,
336
workflow_name: str,
337
run_name: str,
338
action_name: str,
339
**kwargs
340
) -> WorkflowRunAction:
341
"""
342
Get workflow run action details.
343
344
Args:
345
resource_group_name: Name of the resource group
346
name: Name of the logic app
347
workflow_name: Name of the workflow
348
run_name: Name of the run
349
action_name: Name of the action
350
351
Returns:
352
WorkflowRunAction object
353
"""
354
```
355
356
**Usage Example:**
357
358
```python
359
# List actions in a workflow run
360
actions = client.workflow_run_actions.list(
361
resource_group_name="my-resource-group",
362
name="my-logic-app",
363
workflow_name="my-workflow",
364
run_name="08586776228332053649"
365
)
366
367
for action in actions:
368
print(f"Action: {action.name}, Status: {action.status}")
369
370
# Get detailed action information
371
action_details = client.workflow_run_actions.get(
372
resource_group_name="my-resource-group",
373
name="my-logic-app",
374
workflow_name="my-workflow",
375
run_name="08586776228332053649",
376
action_name="HTTP_Action"
377
)
378
print(f"Action inputs: {action_details.inputs}")
379
print(f"Action outputs: {action_details.outputs}")
380
```
381
382
## Workflow Triggers
383
384
### List Triggers
385
386
Get all triggers defined for a workflow.
387
388
```python { .api }
389
def list(
390
self,
391
resource_group_name: str,
392
name: str,
393
workflow_name: str,
394
**kwargs
395
) -> List[WorkflowTrigger]:
396
"""
397
List workflow triggers.
398
399
Args:
400
resource_group_name: Name of the resource group
401
name: Name of the logic app
402
workflow_name: Name of the workflow
403
404
Returns:
405
List of WorkflowTrigger objects
406
"""
407
```
408
409
### Get Trigger
410
411
Retrieve details for a specific trigger.
412
413
```python { .api }
414
def get(
415
self,
416
resource_group_name: str,
417
name: str,
418
workflow_name: str,
419
trigger_name: str,
420
**kwargs
421
) -> WorkflowTrigger:
422
"""
423
Get workflow trigger details.
424
425
Args:
426
resource_group_name: Name of the resource group
427
name: Name of the logic app
428
workflow_name: Name of the workflow
429
trigger_name: Name of the trigger
430
431
Returns:
432
WorkflowTrigger object
433
"""
434
```
435
436
### Run Trigger
437
438
Manually execute a workflow trigger.
439
440
```python { .api }
441
def run(
442
self,
443
resource_group_name: str,
444
name: str,
445
workflow_name: str,
446
trigger_name: str,
447
**kwargs
448
) -> None:
449
"""
450
Run a workflow trigger.
451
452
Args:
453
resource_group_name: Name of the resource group
454
name: Name of the logic app
455
workflow_name: Name of the workflow
456
trigger_name: Name of the trigger
457
"""
458
```
459
460
### Get Trigger History
461
462
Retrieve execution history for a trigger.
463
464
```python { .api }
465
def list(
466
self,
467
resource_group_name: str,
468
name: str,
469
workflow_name: str,
470
trigger_name: str,
471
**kwargs
472
) -> List[WorkflowTriggerHistory]:
473
"""
474
List workflow trigger history.
475
476
Args:
477
resource_group_name: Name of the resource group
478
name: Name of the logic app
479
workflow_name: Name of the workflow
480
trigger_name: Name of the trigger
481
482
Returns:
483
List of WorkflowTriggerHistory objects
484
"""
485
```
486
487
**Usage Example:**
488
489
```python
490
# List triggers in a workflow
491
triggers = client.workflow_triggers.list(
492
resource_group_name="my-resource-group",
493
name="my-logic-app",
494
workflow_name="my-workflow"
495
)
496
497
for trigger in triggers:
498
print(f"Trigger: {trigger.name}, State: {trigger.state}")
499
500
# Run a trigger manually
501
client.workflow_triggers.run(
502
resource_group_name="my-resource-group",
503
name="my-logic-app",
504
workflow_name="my-workflow",
505
trigger_name="manual"
506
)
507
508
# Get trigger execution history
509
trigger_history = client.workflow_trigger_histories.list(
510
resource_group_name="my-resource-group",
511
name="my-logic-app",
512
workflow_name="my-workflow",
513
trigger_name="manual"
514
)
515
516
for history in trigger_history:
517
print(f"Execution: {history.name}, Status: {history.status}, Start Time: {history.start_time}")
518
```
519
520
## Workflow Versions
521
522
### List Versions
523
524
Get all versions of a workflow.
525
526
```python { .api }
527
def list(
528
self,
529
resource_group_name: str,
530
name: str,
531
workflow_name: str,
532
**kwargs
533
) -> List[WorkflowVersion]:
534
"""
535
List workflow versions.
536
537
Args:
538
resource_group_name: Name of the resource group
539
name: Name of the logic app
540
workflow_name: Name of the workflow
541
542
Returns:
543
List of WorkflowVersion objects
544
"""
545
```
546
547
### Get Version
548
549
Retrieve details for a specific workflow version.
550
551
```python { .api }
552
def get(
553
self,
554
resource_group_name: str,
555
name: str,
556
workflow_name: str,
557
version_id: str,
558
**kwargs
559
) -> WorkflowVersion:
560
"""
561
Get workflow version details.
562
563
Args:
564
resource_group_name: Name of the resource group
565
name: Name of the logic app
566
workflow_name: Name of the workflow
567
version_id: Version ID
568
569
Returns:
570
WorkflowVersion object
571
"""
572
```
573
574
**Usage Example:**
575
576
```python
577
# List workflow versions
578
versions = client.workflow_versions.list(
579
resource_group_name="my-resource-group",
580
name="my-logic-app",
581
workflow_name="my-workflow"
582
)
583
584
for version in versions:
585
print(f"Version: {version.name}, Created: {version.created_time}")
586
587
# Get specific version details
588
version_details = client.workflow_versions.get(
589
resource_group_name="my-resource-group",
590
name="my-logic-app",
591
workflow_name="my-workflow",
592
version_id="08586776228332053649"
593
)
594
```
595
596
## Types
597
598
### Workflow
599
600
```python { .api }
601
class Workflow:
602
"""Represents a Logic Apps workflow."""
603
id: Optional[str]
604
name: Optional[str]
605
type: Optional[str]
606
location: Optional[str]
607
tags: Optional[Dict[str, str]]
608
state: Optional[str] # Enabled, Disabled, Deleted, Suspended
609
created_time: Optional[datetime]
610
changed_time: Optional[datetime]
611
version: Optional[str]
612
access_endpoint: Optional[str]
613
definition: Optional[Dict[str, Any]]
614
parameters: Optional[Dict[str, WorkflowParameter]]
615
```
616
617
### WorkflowRun
618
619
```python { .api }
620
class WorkflowRun:
621
"""Represents a workflow execution run."""
622
id: Optional[str]
623
name: Optional[str]
624
type: Optional[str]
625
start_time: Optional[datetime]
626
end_time: Optional[datetime]
627
status: Optional[str] # NotSpecified, Paused, Running, Waiting, Succeeded, Skipped, Suspended, Cancelled, Failed, Faulted, TimedOut, Aborted, Ignored
628
code: Optional[str]
629
error: Optional[Dict[str, Any]]
630
correlation_id: Optional[str]
631
workflow: Optional[ResourceReference]
632
trigger: Optional[WorkflowRunTrigger]
633
outputs: Optional[Dict[str, WorkflowOutputParameter]]
634
```
635
636
### WorkflowRunAction
637
638
```python { .api }
639
class WorkflowRunAction:
640
"""Represents an action executed in a workflow run."""
641
id: Optional[str]
642
name: Optional[str]
643
type: Optional[str]
644
start_time: Optional[datetime]
645
end_time: Optional[datetime]
646
status: Optional[str]
647
code: Optional[str]
648
error: Optional[Dict[str, Any]]
649
tracking_id: Optional[str]
650
correlation: Optional[RunActionCorrelation]
651
inputs_link: Optional[ContentLink]
652
outputs_link: Optional[ContentLink]
653
tracked_properties: Optional[Dict[str, Any]]
654
retry_history: Optional[List[RetryHistory]]
655
```
656
657
### WorkflowTrigger
658
659
```python { .api }
660
class WorkflowTrigger:
661
"""Represents a workflow trigger."""
662
id: Optional[str]
663
name: Optional[str]
664
type: Optional[str]
665
provisioning_state: Optional[str]
666
created_time: Optional[datetime]
667
changed_time: Optional[datetime]
668
state: Optional[str] # NotSpecified, Completed, Enabled, Disabled, Deleted, Suspended
669
status: Optional[str]
670
last_execution_time: Optional[datetime]
671
next_execution_time: Optional[datetime]
672
recurrence: Optional[WorkflowTriggerRecurrence]
673
workflow: Optional[ResourceReference]
674
```
675
676
### WorkflowTriggerHistory
677
678
```python { .api }
679
class WorkflowTriggerHistory:
680
"""Represents trigger execution history."""
681
id: Optional[str]
682
name: Optional[str]
683
type: Optional[str]
684
start_time: Optional[datetime]
685
end_time: Optional[datetime]
686
scheduled_time: Optional[datetime]
687
status: Optional[str]
688
code: Optional[str]
689
error: Optional[Dict[str, Any]]
690
tracking_id: Optional[str]
691
correlation: Optional[Correlation]
692
inputs_link: Optional[ContentLink]
693
outputs_link: Optional[ContentLink]
694
fired: Optional[bool]
695
run: Optional[ResourceReference]
696
```