You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Create loops that repeat actions or process arrays in workflows with Azure Logic Apps
@@ -180,7 +180,7 @@ If you're working in code view, you can define the `For_each` action in your wor
180
180
181
181
By default, the iterations in a **For each** loop run at the same time in parallel. However, when you have nested loops or variables inside the loops where you expect predictable results, you must run the those loops one at a time or sequentially.
182
182
183
-
### [Consumption](#tab/standard)
183
+
### [Consumption](#tab/consumption)
184
184
185
185
1. In the **For each** action's upper right corner, select **ellipses** (**...**) > **Settings**.
186
186
@@ -239,7 +239,7 @@ In the following example workflow, starting at 8:00 AM each day, the **Until** a
239
239
> This example uses Office 365 Outlook, but you can use [any email provider that Azure Logic Apps supports](/connectors/).
240
240
> If you use another email account, the general steps stay the same, but your UI might look slightly different.
241
241
242
-
### [Consumption](#tab/standard)
242
+
### [Consumption](#tab/consumption)
243
243
244
244
1. In the [Azure portal](https://portal.azure.com), create a Consumption logic app resource with a blank workflow.
245
245
@@ -249,15 +249,15 @@ In the following example workflow, starting at 8:00 AM each day, the **Until** a
249
249
250
250
| Property | Value |
251
251
|----------|-------|
252
-
|**Interval**|1|
253
-
|**Frequency**| Day |
254
-
|**At these hours**|8|
252
+
|**Interval**|**1**|
253
+
|**Frequency**|**Day**|
254
+
|**At these hours**|**8**|
255
255
256
-
To add the **At these hours** parameter, open the **Add new parameter** list, and select **At these hours**, which is available only after you set **Frequency** to **Day**.
256
+
To add the **At these hours** parameter, open the **Add new parameter** list, and select **At these hours**, which appears only after you set **Frequency** to **Day**.
257
257
258
258

259
259
260
-
When you're done, the trigger information box looks like the following example:
260
+
When you're done, the **Recurrence** trigger looks like the following example:
261
261
262
262

263
263
@@ -267,9 +267,9 @@ In the following example workflow, starting at 8:00 AM each day, the **Until** a
267
267
268
268
| Property | Value | Description |
269
269
|----------|-------|-------------|
270
-
|**Name**| Limit | Your variable's name |
271
-
|**Type**| Integer | Your variable's data type |
272
-
|**Value**|0| Your variable's starting value |
270
+
|**Name**|**Limit**| Your variable's name |
271
+
|**Type**|**Integer**| Your variable's data type |
272
+
|**Value**|**0**| Your variable's starting value |
273
273
274
274

275
275
@@ -281,7 +281,7 @@ In the following example workflow, starting at 8:00 AM each day, the **Until** a
281
281
282
282
1. From the list, under **Variables**, select the variable named **Limit**.
283
283
284
-
1. From the middle operator list, select the **is equal** operator.
284
+
1. From the middle operator list, select the **is equal to** operator.
285
285
286
286
1. In the rightmost box named **Choose a value**, enter **10** as the comparison value.
287
287
@@ -300,7 +300,7 @@ In the following example workflow, starting at 8:00 AM each day, the **Until** a
300
300
301
301

302
302
303
-
1. Outside and under the loop, [follow these general steps to add an action that sends email](create-workflow-with-trigger-or-action.md?tabs=consumption#add-action).
303
+
1. Outside and under **Until** action, [follow these general steps to add an action that sends email](create-workflow-with-trigger-or-action.md?tabs=consumption#add-action).
304
304
305
305
This example continues with the **Office 365 Outlook** action named **Send an email**.
306
306
@@ -320,38 +320,119 @@ In the following example workflow, starting at 8:00 AM each day, the **Until** a
320
320
321
321
### [Standard](#tab/standard)
322
322
323
+
1. In the [Azure portal](https://portal.azure.com), create a Standard logic app resource with a blank workflow.
324
+
325
+
1. In the designer, [follow these general steps to add the **Recurrence** built-in trigger named **Schedule** to your workflow](create-workflow-with-trigger-or-action.md?tabs=standard#add-trigger).
326
+
327
+
1. In the **Recurrence** trigger information pane, on the **Parameters** tab, specify the interval, frequency, and hour of the day for the trigger to fire.
328
+
329
+
The **At These Hours** parameter appears only after you set **Frequency** to **Day**.
330
+
331
+
| Property | Value |
332
+
|----------|-------|
333
+
|**Interval**|**1**|
334
+
|**Frequency**|**Day**|
335
+
|**At These Hours**|**8**|
336
+
337
+
When you're done, the **Recurrence** trigger information pane looks like the following example:
338
+
339
+

340
+
341
+
1. Under the trigger, [follow these general steps to add the **Variables** built-in action named **Initialize variable** to your workflow](create-workflow-with-trigger-or-action.md?tabs=standard#add-action).
342
+
343
+
1. In the **Initialize variable** action information pane, on the **Parameters** tab, provide the following values:
344
+
345
+
| Property | Value | Description |
346
+
|----------|-------|-------------|
347
+
|**Name**|**Limit**| Your variable's name |
348
+
|**Type**|**Integer**| Your variable's data type |
349
+
|**Value**|**0**| Your variable's starting value |
350
+
351
+

352
+
353
+
1. Under the **Initialize variable** action, [follow these general steps to add the **Control** built-in action named **Until** to your workflow](create-workflow-with-trigger-or-action.md?tabs=standard#add-action).
354
+
355
+
1. In the **Until** action information pane, on the **Parameters** tab, provide the following values to set up the stop condition for the loop.
356
+
357
+
1. Under **Loop Until**, select inside the leftmost box named **Choose a value**, and select the option to open the dynamic content list (lightning icon).
358
+
359
+
1. From the list, under **Variables**, select the variable named **Limit**.
360
+
361
+
1. From the middle operator list, select the **is equal to** operator.
362
+
363
+
1. In the rightmost box named **Choose a value**, enter **10** as the comparison value.
364
+
365
+

366
+
367
+
1. Inside the **Until** action, select the plus (**+**) sign, and then select **Add an action**.
368
+
369
+
1.[Follow these general steps to add the **Variables** built-in action named **Increment variable** to the **Until** action](create-workflow-with-trigger-or-action.md?tabs=standard#add-action).
370
+
371
+
1. In the **Increment variable** action information pane, provide the following values to increment the **Limit** variable's value by 1:
372
+
373
+
| Property | Value |
374
+
|----------|-------|
375
+
|**Name**| Select the **Limit** variable. |
376
+
|**Value**|**1**|
377
+
378
+

379
+
380
+
1. Outside and under the **Until** action, [follow these general steps to add an action that sends email](create-workflow-with-trigger-or-action.md?tabs=standard#add-action).
381
+
382
+
This example continues with the **Office 365 Outlook** action named **Send an email**.
383
+
384
+
1. In the email action information pane, on the **Parameters** tab, provide the following values:
385
+
386
+
| Property | Value | Description |
387
+
|----------|-------|-------------|
388
+
|**To**| <*email-address\@domain*> | The recipient's email address. For testing, use your own email address. |
389
+
|**Subject**|**Current value for "Limit" variable is:****Limit**| The email subject. For this example, make sure that you include the **Limit** variable to confirm that the current value meets your specified condition: <br><br>1. Select inside the **Subject** box so that the dynamic content list appears. <br><br>2. In the dynamic content list, next to the **Variables** section header, select **See more**. <br><br>3. Select **Lmiit**. |
390
+
|**Body**| <*email-content*> | The email message content that you want to send. For this example, enter whatever text you want. |
391
+
392
+
When you're done, your email action looks similar to the following example:
393
+
394
+

395
+
396
+
1. Save your workflow.
397
+
323
398
---
324
399
325
400
### Test your workflow
326
401
327
-
1.To manually test your logic app, on the designer toolbar, select **Run Trigger** > **Run**.
402
+
To manually test your logic app workflow, follow the steps based on whether you have a Consumption or Standard logic app.
328
403
404
+
### [Consumption](#tab/consumption)
329
405
330
-
After your workflow starts running, you get an email with the content that you specified:
406
+
On the designer toolbar, select **Run Trigger** > **Run**.
1. On the **Overview** page toolbar, select **Run** > **Run**.
337
413
338
-
The "Until" loop stops execution based on these properties, so make sure that you set their values accordingly:
414
+
---
339
415
340
-
***Count**: This value is the highest number of loops that run before the loop exits. For the default and maximum limits on the number of "Until" loops that a logic app run can have, see [Concurrency, looping, and debatching limits](../logic-apps/logic-apps-limits-and-config.md#looping-debatching-limits).
416
+
After your workflow starts running, you get an email with the content that you specified:
417
+
418
+

419
+
420
+
<aname="prevent-endless-loops"></a>
341
421
342
-
***Timeout**: This value is the most amount of time that the "Until" action, including all the loops, runs before exiting and is specified in [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601). For the default and maximum limits on the **Timeout** value, see [Concurrency, looping, and debatching limits](../logic-apps/logic-apps-limits-and-config.md#looping-debatching-limits).
422
+
### Prevent endless loops
343
423
344
-
The timeout value is evaluated for each loop cycle. If any action in the loop takes longer than the timeout limit, the current cycle doesn't stop. However, the next cycle doesn't start because the limit condition isn't met.
424
+
The **Until** action stops execution based on the following properties, which you can view by selecting **Change limits** in the action. Make sure that you set these property values accordingly:
345
425
346
-
To change these limits, in the loop action, select **Change limits**.
426
+
| Property | Description |
427
+
|----------|-------------|
428
+
|**Count**| The maximum number of iterations that run before the loop exits. <br><br>For the default and maximum limits on the number of **Until** actions that a workflow can have, see [Concurrency, looping, and debatching limits](logic-apps-limits-and-config.md#looping-debatching-limits). |
429
+
|**Timeout**| The maximum amount of time that the **Until** action, including all iterations, runs before the loop exits. This value is specified in [ISO 8601 format](https://en.wikipedia.org/wiki/ISO_8601) and is evaluated for each iteration. <br><br>If any action in the loop takes longer than the timeout limit, the current iteration doesn't stop. However, the next iteration doesn't start because the timeout limit condition is met. <br><br>For the default and maximum limits on the **Timeout** value, see [Concurrency, looping, and debatching limits](../logic-apps/logic-apps-limits-and-config.md#looping-debatching-limits). |
347
430
348
431
<aname="until-json"></a>
349
432
350
433
## "Until" definition (JSON)
351
434
352
-
If you're working in code view for your logic app,
353
-
you can define an `Until` loop in your logic app's
354
-
JSON definition instead, for example:
435
+
If you're working in code view, you can define an `Until` action in your workflow's JSON definition, for example:
355
436
356
437
```json
357
438
"actions": {
@@ -389,18 +470,14 @@ JSON definition instead, for example:
389
470
}
390
471
```
391
472
392
-
This example "Until" loop calls an HTTP endpoint,
393
-
which creates a resource. The loop stops when the
394
-
HTTP response body returns with `Completed` status.
395
-
To prevent endless loops, the loop also stops
396
-
if any of these conditions happen:
473
+
This example **Until** loop calls an HTTP endpoint, which creates a resource. The loop stops when the
474
+
HTTP response body returns with `Completed` status. To prevent endless loops, the loop also stops
475
+
if any of the following conditions happen:
397
476
398
-
* The loop ran 10 times as specified by the `count` attribute.
399
-
The default is 60 times.
477
+
* The loop ran 10 times as specified by the `count` attribute. The default is 60 times.
478
+
479
+
* The loop ran for two hours as specified by the `timeout` attribute in ISO 8601 format. The default is one hour.
400
480
401
-
* The loop ran for two hours as specified by the `timeout` attribute in ISO 8601 format.
402
-
The default is one hour.
403
-
404
481
```json
405
482
"actions": {
406
483
"myUntilLoopName": {
@@ -431,16 +508,9 @@ The default is one hour.
431
508
}
432
509
```
433
510
434
-
## Get support
435
-
436
-
* For questions, visit the
437
-
[Microsoft Q&A question page for Azure Logic Apps](/answers/topics/azure-logic-apps.html).
438
-
* To submit or vote on features and suggestions,
439
-
[Azure Logic Apps user feedback site](https://aka.ms/logicapps-wish).
440
-
441
511
## Next steps
442
512
443
-
*[Run steps based on a condition (condition action)](../logic-apps/logic-apps-control-flow-conditional-statement.md)
444
-
*[Run steps based on different values (switch action)](../logic-apps/logic-apps-control-flow-switch-statement.md)
445
-
*[Run or merge parallel steps (branches)](../logic-apps/logic-apps-control-flow-branches.md)
446
-
*[Run steps based on grouped action status (scopes)](../logic-apps/logic-apps-control-flow-run-steps-group-scopes.md)
513
+
*[Run steps based on a condition (condition action)](logic-apps-control-flow-conditional-statement.md)
514
+
*[Run steps based on different values (switch action)](logic-apps-control-flow-switch-statement.md)
515
+
*[Run or merge parallel steps (branches)](logic-apps-control-flow-branches.md)
516
+
*[Run steps based on grouped action status (scopes)](logic-apps-control-flow-run-steps-group-scopes.md)
0 commit comments