How to bypass the expiration limit in Power Automate

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

PLEASE NOTE THAT THERE HAS BEEN A CHANGE IN THE WAY MICROSOFT HAS FORMATTED THE URL IN THE EMAIL WE NEED TO TRANSFORM. FOR AN UPDATE ON THIS, REFER TO THIS BLOGPOST

Expiration limits

First of all, let’s clarify which limits apply to which plans.

Free/Trial 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?

Notifications

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.

Automatically turn on flows

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:

  • Trigger
  • Variables
  • Turn on flow
  • Delete email

Trigger

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:

Variables

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

Or, when your flow is shared with other co-owners:

https://flow.microsoft.com/manage/environments/<ENVIRONMENT ID>/flows/shared/<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:

Environment ID

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

Flow ID

first(
	split(
		last(
			split(
				replace(
					triggerOutputs()?['body/body'],
						'/shared',
						''
					),
				'/flows/'
			)
		),
	'/'
	)
)

This will remove a possible ‘/shared’ string from the URL (using the replace() expression) inside the HTML contents of the email. This happens only for flows that have been shared with other co-owners; if the flow hasn’t been shared, this part of the expressions will be skipped. After that, the result will be splitted, 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:

  • Environment
  • Flow

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:

Delete email

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.

Summary

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:

14 Replies to “How to bypass the expiration limit in Power Automate”

    1. That is correct, I’ve recently updated this blogpost with a reference to a new blogpost that explains how to handle this change. The link to the new blogpost is in the top section of this blogpost

      0
      0
  1. Just a heads up, if you use M365 safe links protection, you need to change the initialise variables to the following:

    varEnvironment:

    first(
    split(
    last(
    split(
    triggerOutputs()?[‘body/body’],
    ‘https%253A%252F%252Fflow.microsoft.com%252Fmanage%252Fenvironments%252F’
    )
    ),
    ‘%252F’
    )
    )

    varFlow:

    first(
    split(
    last(
    split(
    replace(
    triggerOutputs()?[‘body/body’],
    ‘%252Fshared’,

    ),
    ‘%252Fflows%252F’
    )
    ),
    ‘%252F’
    )
    )

    1
    0
  2. Which expression type is used for the initialize variable section for pulling out the environment/flow id?

    0
    0
    1. I just had a flow re-enabled using this 13 hours ago so it still seems to be working on my end. Are you sure it was an inactive flow disablement and not a flow error disablement?
      The sender doesn’t really matter in this case because you’re only checking on subject (which is still the same in the email I got 13 hours ago). In my case the inactive flow notification is sent from my own account, not from the maccount or the PowerAutomateNoReply account. Because of this, I think you’ve received another mail, not related to the inactivity of your flow.

      0
      0
  3. Getting the Flow ID differs when the flow is shared. To be able to extract the Flow ID when the flow is shared, a replace method was added in the expression.

    Final result:
    first(split(last(split(replace(triggerOutputs()?[‘body/body’],’/shared’,”),’/flows/’)),’/’))

    If the flow is not shared, the replace method does nothing and the rest of the expression will still work.

    2
    0
    1. Good addition, I already found out myself that the link differs when using a shared flow. I will update my blogpost soon with these new expression. Thanks for your input!

      2
      0
  4. Thanks for posting! I would recommend to use a service account (with an Exchange license) so this scenario still works after you leave the organization.

    1
    0
    1. Thanks for the addition. I agree; a service account should be used for every business flow to avoid getting stuck after the owner leaves the organization

      2
      0

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.