Do you want to re-enable flows that were suspended automatically? Have you noticed that flows that aren’t running are automatically switched off?
Switched off flows
This can be very annoying! you have a flow that doesn’t run very often and after 30 days these flows are being switched off!
I’ve never understood this feature and even wore, as far as I know there is no way of disabling the disabling of the flows.
So, how do we stop this or avoid flows not running and being stopped?
I was thinking that we could just create a flow. Actually, maybe we should create two flows to re-enable flows that have been stopped.
Well, what if my flow doesn’t run for 30 days? Alternatively I can schedule my re-enable flow to run daily and I will not have a problem.
Building the Re-enable flow
I’m going to create a scheduled flow that will ruin daily.
Then I’m going to collect all the flows that I’ve got using the Get Environments and the List Flows as Admin actions.
From the output we can now see some of the details of my flows.
Ok, that is good but that gives me a lot of data to process. A typical mistake to now make id to extend that apply to each with another apply to each so that we nest our apply to each steps. Unless you want to make a lot of coffees, you better use the Pieter’s method.
We will only need the flow name, the environment name and the status. Using the select I’m just going to create records for these three properties.
Looking in the run mode this will give us an array of just the properties that we want.
However we are not interested in the started flows, we just want to ones that have been suspended. Flows that have a stopped status were stopped by someone suspended flows are flows that were stopped by Microsoft because they didn’t run or they caused too many failures.
To get just the suspended flows I’m going to add a filter, just before the select action.
All we need to add in the Compose is the following code:
Note that you will have to type this as the dynamic content will not show the out of scope content.
Ok, I could still transform my json from that compose a bit, but I’m going to be lazy this time. Just a nested apply to each to process the flows for each environment and switch them back on.
The flow part of this will look like this. Using the turn on flow action
There are 4 pieces of code here. in the Apply to each 2:
In the apply to each 3 :
In the Turn On flow:
and for the Flow :
And as a result all my flows have been re-enabled within a minute.
You could of course also add an email telling the users that the flow was suspended by accident and that they can ignore that email that was sent out to them.