cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Mikael_Svenson
Level: Powered On

How to architect long running flows which exceed the 30 day timeout limit in Microsoft Flow

 [Original article: http://www.techmikael.com/2018/01/how-to-architect-long-running-flows.html]

 

Microsoft Flow has a built in timeout of 30 days for any running Flow (Logic Apps has 90 days), which for most scenarios is not a problem.

 

However, there are business processes that might run longer than 30 days, and I’ll address two common scenarios and how to overcome them:

 

  1. Any single action will never last 30 days, but the total Flow might
  2. A single action might take more than 30 days

 

See https://docs.microsoft.com/en-us/flow/limits-and-config for details on Flow limit and see https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-limits-and-config for limits on Logic Apps.

 
Scenario 1: Any single action will never last 30 days, but the total Flow might

 

Let’s imagine you have 5 consecutive actions in your flow, where there is no chance that any of them will run for more than 30 days. For example 5 consecutive approval steps. The way to work around this is to create one flow per approval, and then have them call each other as they go along.

 

To illustrate the steps I have created two flows. One named “Flow – Initial” and the other “Flow – 2”.

I’ll start with the second flow, as this will be called from the first.


This takes a HTTP request as input. In this case two parameters, a title and description, which is used in the an approval action. After you save this flow, copy the POST URL, which you will need in the initial flow.

image

 

The initial flow takes input from the user, and then calls the second flow, a pattern you can use to continue calling the third flow etc..

 

image

 
Scenario 2: A single action might take more than 30 days

 

Again, let’s take a look at an approval flow. You start an approval task i a Flow, but it could take more than 30 days before someone accepts or rejects it.

 

Again you need one initial flow which kicks it all off. This can be a Flow button, or any other trigger which grabs the initial input.

The key is to generate a JSON object with all the needed data which you can use in the flow with the actual business logic.

I’ll use Flow – 2 as my staring point, and the idea is to have this Flow call itself as long as needed until the approval is accepted or rejected.

 

First I’ll access the settings for the Approval action.

 

image

 

As I mentioned at the beginning, the default max timeout is 30 days in Microsoft Flow. The idea is to restart the flow if it times out within this boundary. You don’t have the possibility to perform actions if the flow itself times out, but we can act on when a single action times out.

 

If you set the action timeout to 29 days it’s guaranteed to timeout before the whole flow times out. To test it out you can set the timeout lower, for example 15 minutes (PT15M).

 

image

 

After the approval action add an HTTP action with the same URL as the HTTP trigger and the same Body – which is the data you passed in with a title and description. Next open the Configure run after option.

 

image

 

Uncheck the is successful option, and check the has timed out option.

 

image

 

The effect of this is that if the Approval was approved or rejected within 29 days, then all is good. If not, the approval request will actually be removed and a new one is issued by re-running the flow.

 

Of course, you might want to add e-mail alerts or other logic when an action times out before you re-try it. You could also add a parameter in the initial JSON data saying which run this is, and then increment per run if you want to re-try X number of times. Either way you should have a staring point to continue building out the logic you need for long running flow.

 
Summary

 

Even though a Microsoft Flow times out after 30 days, there are ways to architect yourself around this by using multiple flows which either call on each other, or call on themselves. Or if a timeout within 90 days works for you, you could move your Microsoft Flow to run as a Logic App instead.

Thanks,
Mikael Svenson
Microsoft MVP
4 REPLIES 4
Administrator
Administrator

Re: How to architect long running flows which exceed the 30 day timeout limit in Microsoft Flow

Thank you so much for sharing this! 

 

This is an incredible workaround to a current Flow limitation!

Re: How to architect long running flows which exceed the 30 day timeout limit in Microsoft Flow

Thank you for sharing @Mikael_Svenson.

 

Simple for implementation and effective.

wsfn
Level: Power Up

Re: How to architect long running flows which exceed the 30 day timeout limit in Microsoft Flow

I am creating a simple flow to send an email 90 days after a file is created.  I am using "Delay" as my wait between trigger and action.  I just had it fail in the first real-world application as I had noted a 90 day delay... and realized the 30 day max.  I have added 2 more 30 day delays after the first... am I reading that this will all time out in 30 days anyway? 

Will the solution for re-running the flow work in my case?  I guess I would restrict it to only 3 runs to equal the 90 days?

feilda
Level: Powered On

Re: How to architect long running flows which exceed the 30 day timeout limit in Microsoft Flow

This is very helpful. I am wondering if you can take it one step further in your example.  I have a flow that is triggered by a person submitting a request.  The request is then picked up by a team and sent through a series of phases to complete the request.  There is no approval involved.  At the point of submitting the request an auto generated email is sent to the requester.  Then at each phase the team changes the phase level on the list and a new email is generated to the requester to advise them of the current phase and what is needed.  

 

Do you have any diagrams of this type of flow that would prevent the 30 day timeout from running?

 

 

PART 1.PNGPART 2.PNGPART 3.PNGPART 4.PNGPART 5.PNGPART 6.PNGPART 7.PNG

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,969)