Skip to content

Commit 84176e1

Browse files
author
ecfan
committed
Draft updates
1 parent 8891646 commit 84176e1

6 files changed

Lines changed: 117 additions & 47 deletions

articles/logic-apps/logic-apps-control-flow-loops.md

Lines changed: 117 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: logic-apps
55
ms.suite: integration
66
ms.reviewer: estfan, azla
77
ms.topic: how-to
8-
ms.date: 08/18/2023
8+
ms.date: 09/13/2023
99
---
1010

1111
# 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
180180

181181
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.
182182

183-
### [Consumption](#tab/standard)
183+
### [Consumption](#tab/consumption)
184184

185185
1. In the **For each** action's upper right corner, select **ellipses** (**...**) > **Settings**.
186186

@@ -239,7 +239,7 @@ In the following example workflow, starting at 8:00 AM each day, the **Until** a
239239
> This example uses Office 365 Outlook, but you can use [any email provider that Azure Logic Apps supports](/connectors/).
240240
> If you use another email account, the general steps stay the same, but your UI might look slightly different.
241241
242-
### [Consumption](#tab/standard)
242+
### [Consumption](#tab/consumption)
243243

244244
1. In the [Azure portal](https://portal.azure.com), create a Consumption logic app resource with a blank workflow.
245245

@@ -249,15 +249,15 @@ In the following example workflow, starting at 8:00 AM each day, the **Until** a
249249

250250
| Property | Value |
251251
|----------|-------|
252-
| **Interval** | 1 |
253-
| **Frequency** | Day |
254-
| **At these hours** | 8 |
252+
| **Interval** | **1** |
253+
| **Frequency** | **Day** |
254+
| **At these hours** | **8** |
255255

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**.
257257

258258
![Screenshot shows Azure portal, Consumption workflow designer, and Recurrence trigger parameters with selected option for At these hours.](./media/logic-apps-control-flow-loops/do-until-trigger-consumption.png)
259259

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:
261261

262262
![Screenshot shows Azure portal, Consumption workflow, and Recurrence trigger parameters set up.](./media/logic-apps-control-flow-loops/do-until-trigger-complete-consumption.png)
263263

@@ -267,9 +267,9 @@ In the following example workflow, starting at 8:00 AM each day, the **Until** a
267267

268268
| Property | Value | Description |
269269
|----------|-------|-------------|
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 |
273273

274274
![Screenshot shows Azure portal, Consumption workflow, and parameters for built-in action named Initialize variable.](./media/logic-apps-control-flow-loops/do-until-loop-variable-properties-consumption.png)
275275

@@ -281,7 +281,7 @@ In the following example workflow, starting at 8:00 AM each day, the **Until** a
281281

282282
1. From the list, under **Variables**, select the variable named **Limit**.
283283

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.
285285

286286
1. In the rightmost box named **Choose a value**, enter **10** as the comparison value.
287287

@@ -300,7 +300,7 @@ In the following example workflow, starting at 8:00 AM each day, the **Until** a
300300

301301
![Screenshot shows Consumption workflow and built-in action named Until with Name set to the Limit variable and Value set to 1.](./media/logic-apps-control-flow-loops/do-until-loop-increment-variable-consumption.png)
302302

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).
304304

305305
This example continues with the **Office 365 Outlook** action named **Send an email**.
306306

@@ -320,38 +320,119 @@ In the following example workflow, starting at 8:00 AM each day, the **Until** a
320320

321321
### [Standard](#tab/standard)
322322

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+
![Screenshot shows Azure portal, Standard workflow, and Recurrence trigger parameters set up.](./media/logic-apps-control-flow-loops/do-until-trigger-standard.png)
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+
![Screenshot shows Azure portal, Standard workflow, and parameters for built-in action named Initialize variable.](./media/logic-apps-control-flow-loops/do-until-loop-variable-properties-standard.png)
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+
![Screenshot shows Standard workflow and built-in action named Until with finished stop condition.](./media/logic-apps-control-flow-loops/do-until-loop-settings-standard.png)
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+
![Screenshot shows Standard workflow and built-in action named Until with Name set to the Limit variable and Value set to 1.](./media/logic-apps-control-flow-loops/do-until-loop-increment-variable-standard.png)
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+
![Screenshot shows Standard workflow and action named Send an email with property values.](./media/logic-apps-control-flow-loops/do-until-loop-send-email-standard.png)
395+
396+
1. Save your workflow.
397+
323398
---
324399

325400
### Test your workflow
326401

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.
328403

404+
### [Consumption](#tab/consumption)
329405

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**.
331407

332-
![Received email](./media/logic-apps-control-flow-loops/do-until-loop-sent-email.png)
408+
### [Standard](#tab/standard)
333409

334-
<a name="prevent-endless-loops"></a>
410+
1. On the workflow menu, select **Overview**.
335411

336-
## Prevent endless loops
412+
1. On the **Overview** page toolbar, select **Run** > **Run**.
337413

338-
The "Until" loop stops execution based on these properties, so make sure that you set their values accordingly:
414+
---
339415

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+
![Screenshot shows sample email received from example workflow.](./media/logic-apps-control-flow-loops/do-until-loop-sent-email.png)
419+
420+
<a name="prevent-endless-loops"></a>
341421

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
343423

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:
345425

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). |
347430

348431
<a name="until-json"></a>
349432

350433
## "Until" definition (JSON)
351434

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:
355436

356437
``` json
357438
"actions": {
@@ -389,18 +470,14 @@ JSON definition instead, for example:
389470
}
390471
```
391472

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:
397476

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.
400480

401-
* The loop ran for two hours as specified by the `timeout` attribute in ISO 8601 format.
402-
The default is one hour.
403-
404481
``` json
405482
"actions": {
406483
"myUntilLoopName": {
@@ -431,16 +508,9 @@ The default is one hour.
431508
}
432509
```
433510

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-
441511
## Next steps
442512

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)
33.8 KB
Loading
58.5 KB
Loading
35.9 KB
Loading
24.3 KB
Loading
39.7 KB
Loading

0 commit comments

Comments
 (0)