Quantcast
Channel: blog.atwork.at
Viewing all articles
Browse latest Browse all 1118

How to restore a flow from a backup to another environment

0
0

In the previous article, we showed and described two flows to backup and restore a flow. This works well when the flow's connections are still in the same environment. But what about restoring a flow in a different environment? This is a typical use case for "moving" flows from a source environment to a target environment, such as from the development environment to the productive or department environment. In this article we show how this works with the restore flow.

Scenario

We have flow backups stored in a SharePoint document library as json and text files as described in Backup a flow. We want to restore a flow with the Restore a flow flow into another environment. For that, we need to (create and) adapt the connections of the flow.

Requirements: Connections must exist

To create a flow with the Power Automate Management action Create Flow, we pass the flow definition and the connectionReferences to the action. The action requires that the connections are already existing. As the name connectionReferences says, the flow stores references to existing API connections in the target environment.

image

Well, this is not the case if we restore a flow into a different environment. So, we need to take care that

  1. the connections are existing in the target environment, and
  2. we must adapt the connections when we create the flow in the target environment.

Create or use the required connections for each flow

As we see, before we can restore a flow with the Restore1flow flow, we need to

  • use existing connections, or
  • create new connections in the target environment.

We can accomplish this in the Power Automate page at

https://make.powerautomate.com/environments/<target-environment>/connections

First, select the target-environment (1). Then open the Data menu (2) and Connections (3). Check, if there are existing connections here (5) that you can use, or create new connections (4). Authenticate all connectors, so that they are connected.

image

We now need the connection data for the restore process of the flow. Click on the connection and save the URL. This looks as here:

https://make.powerautomate.com/environments/<target-environment>/connections?apiName=<apiName>&connectionName=<connectionName>
  • Save the apiName and the connectionName to a notepad or similar
  • Repeat that for every connection the flow is using

So we have a list of new connections we need for the flow, our "connectors-list".

Create a connection with a flow

There´s also an action in the Flow connector named "Create Connection" to automate this process as well. Depending on the Connector, the form asks for additional parameters and for authentication, For example, to create a new Office 365 Outlook connection in a selected environment, the flow would look as here.

image

There are no parameters for this connector. When we run this flow, it creates a new connection in the selected environment which looks as here.

image

The user needs to click on the Fix connection link and to sign-in. Then, the connection status changes to Connected and the connection can be used.

Now we do the same as described above to update our connectors-list. We click on the connection name and write down the connection apiName (here it´s shared_office365), and connectionName (which is an Id) in the URL, like here:

https://make.powerautomate.com/environments/<target-environment>/connections?apiName=shared_office365&connectionName=<your-connectionName>

We will use them in the CreateFlow.

Note: Some connectors do not make sense for us. For example, connecting to SharePoint Online with a simple username and password will never work in a world with Modern Authentication and MFA.

image

So, creating some connectors is not functional, but most connectors can be created this way.

Connections must always be completed with authorization

The creation of connections can therefore only be partially automated. A manual part is always required as described above.

You need to create the connections in the target environment with a flow or manually, and you need to authenticate the connectors.

Finalize and modify the connections file

To restore the flow in the target environment, we need to modify all connections in the flowname-connection.txt file. This file has been created in the Backup1Flow flow and has been saved to a SharePoint list, see How to backup and restore a flow with another flow.

We can accomplish that manually, or develop an extra flow that does the replacements of the stored connections with the new connectionNames we collected in our own connectors-list, as here.

[

  {
    "connectionName": "<your-connectionName>",
    "id": "/providers/Microsoft.PowerApps/apis/shared_office365"
  },
  { <next-connection…> }
]

Then, adapt the target environment in the Restore1flow and run it. The flow should be restored using the new connections.

Restoring done

With these data transformation workarounds of the connections, we can restore a saved flow to a new target environment. You can find the two flows to download and import into your own Flow environment in my PowerPlatformGovernance repository in GitHub.

This process is often part of a cleanup and governance process. We hope this practical guide will help you easily backup and restore your own flows, also in other environments.


Viewing all articles
Browse latest Browse all 1118

Latest Images

Trending Articles