We’ve all experienced it or heard about it: Microsoft will turn off your flow if it hasn’t ran in the past 60 or 90 days. Most of your flows will possibly never experience this, but there are cases that will require some manual monitoring to make sure your flow doesn’t turn off accidentally.
In this blog, I’ll explain how you can by-pass this expiration limit
First of all, let’s clarify which limits apply to which plans.
When you are using a free/trial plan (a plan that is not included within your Microsoft 365 plan), the expiration limit is set to 60 days. Meaning your flow will be turned off after 60 days of not having any successful triggers.
Microsoft 365 plans
When you are using a Power Automate license within your Microsoft 365 plan, the expiration limit is set to 90 days. Meaning your flow will be turned off after 90 days of not having any successful triggers.
Power Automate plan
When you are using a standalone Power Automate plan (e.g. Per flow plan), your flow will not be turned off. Even after months of not having any successful triggers. But having a premium license just for this sole purpose is a bit overkill isn’t it? So how do we prevent flows from accidentally being turned off?
When your flow is about to expire, the flow owner(s) will receive an email message, stating the flow is about to expire and it will be turned off in 7 days:
This should mean you should manually trigger the flow to make sure it won’t be turned off in 7 days. If you don’t do this, 7 days later you will receive a notification that your flow has been turned off:
This is where you can manually turn your flow back on, but then there is a possibility you have missed some flow runs.
As described above, you can act manually on the notifications you’ll receive. A better way is to automate this process so you won’t be bothered with manual labor. We need to configure the following for this:
- Turn on flow
- Delete email
The second notification mail (in which you’ll get informed the flow has been turned off) is a good starting point. We have a trigger (a new email), including filtering options (subject is always the same for these emails: Alert! Your flow has been turned off since it was not running). So we just create a new flow that has the When a new email arrives (V3) trigger from the Office 365 Outlook connector in it and we configure it as follows:
We also have all the other information we need to turn our flow back on:
- Environment ID
- Flow ID
These two parameters can be extracted by doing some ‘magic’ on the HTML content of the email itself. The email contains a button that will lead you to the flow, using the default URL:
https://flow.microsoft.com/manage/environments/<ENVIRONMENT ID>/flows/<FLOW ID>/details/...
To extract the environment ID and the flow ID, we add to Initialize variable actions into our flow and configure it as follows:
first( split( last( split( triggerOutputs()?['body/body'], 'https://flow.microsoft.com/manage/environments/' ) ), '/' ) )
This will split the HTML contents of the email, starting from the https://flow.microsoft.com/manage/environments/ part (which is the link behind the button) and pick the last part of the HTML contents after this string. This outcome will be split again, but now by the next slash (/) and will pick the first part before this string, giving us the part between /environments/ and the next slash (which is our Environment ID).
first( split( last( split( triggerOutputs()?['body/body'], '/flows/' ) ), '/' ) )
This will split the HTML contents of the email, starting from the /flows/ part (which is the flows part of the link behind the button) and pick the last part of the HTML contents after this string. This outcome will be split again, but now by the next slash (/) and will pick the first part before this string, giving us the part between /flows/ and the next slash (which is our flow ID).
Turn on flow
Now that we have our environment ID and our flow ID, we can proceed by turning the flow on again. We can do that by using the Turn on flow action from the Power Automate Management connector. This action asks for 2 parameters:
These are the IDs we configured earlier into our two variables, so we can just add them from our Dynamic Content into the action itself:
After the flows has been turned on, we no longer need the email informing us that the flow has been turned off so we can automatically delete this email by using the Move email (V2) action from the Office 365 Outlook connector and providing the Message Id from the Dynamic Content of your trigger and selecting the Deleted items folder:
Please note that when you use the Delete email (V2) action, the email gets deleted from your mailbox (unlike manually deleting, which will place the email in the Deleted items folder). When using this, you cannot use the solution I describe in the next chapter.
After successfully configuring your flow, you will no longer need to take action when a flow is about to expire. Your entire flow should look like this:
Please note that this flow is also due to expiration if it doesn’t run regularly. To avoid this flow from being turned off, you can create a second flow that will run monthly and will just pick up the last notification email from your Deleted items folder and just resend it to yourself. That will trigger this flow every month so it won’t be turned off: