DEV Community

Cover image for Using Power Automate Flow for Exporting and Importing Solutions
Fernanda Ek
Fernanda Ek

Posted on

Using Power Automate Flow for Exporting and Importing Solutions

In today's post, I'll show you an easy way to export and import your Power Platform solutions using Power Automate 😉

This method is a simpler alternative to pipelines in Power Platform and helps you keep everything in sync across your environments without the need for managed environments (though managed environments do offer great benefits like better security and governance). Power Automate makes it super straightforward, especially if you’re looking for a quick and cost-effective solution.


Dataverse PREMIUM: Perform an unbound action

This is action is used to perform actions that aren’t tied to specific records, like exporting a whole solution from one environment and importing it into another.
It lets us make changes that affect the entire Dataverse, not just one specific record.
Image description

Configure the flow to export the solution

Once the "Perform an unbound action" is selected, it's time to configure the action to perform the export of the solution.

  • Action Name: Set this to ExportSolution This specifies that the action to be performed is exporting a solution.
  • SolutionName: Input the name of the solution you want to export. You can use dynamic content if you're pulling the solution name from a previous step (like from a SharePoint list or a text input in the trigger).
  • Managed: Choose "Yes" if you want to export the solution as managed (which cannot be modified once imported) or "No" for unmanaged.
  • TargetVersion: Specify the version of the Dataverse to which the solution will be exported.

Image description

Solution backup

I store the solution versions in a SharePoint library and from there I can trigger the import/export process.
Image description

To do so use the following expression to create a file with the exported content:

base64ToBinary(Body('Perform_an_unbound_action')?['ExportSolutionFile'])

Enter fullscreen mode Exit fullscreen mode

Image description

Configure the flow to import the solution

The ImportSolution-action will import the solution into the same environment where your flow is running. So, if your flow is set up in the target environment, that's where the solution will be imported.

Let's consider that the flow is already created in an environment called "Test." In this case, when you run the flow, the solution will be imported directly into the "Test" environment. You don't need to worry about specifying the target environment.

For this purpose, I have a JSON-button in my SharePoint library already configured with the flowID and environmentID

Image description

Now in the target environment, let's configure the action to perform the import.

Image description

  • Action Name: Set this to ImportSolution, this specifies the task of importing a solution.
  • OverwriteUnmanagedCustomizations: If set to "Yes," it’ll replace any existing customization in the target environment.
  • PublishWorkflows: Set to "Yes" to automatically activate workflows after importing.
  • CustomizationFile: The file content you're importing, either the content from a previous export or the file content stored in SharePoint.
body('Perform_an_unbound_action')?['ExportSolutionFile']

Enter fullscreen mode Exit fullscreen mode

Image description

  • ImportJobId: This is a unique ID for the import task, so we can generate a uniqueID for our export/import.
guid()
Enter fullscreen mode Exit fullscreen mode
  • ConvertToManaged: Change the solution to managed if set to "Yes."
  • ComponentParameters: Add extra settings for the solution components.
  • SolutionParameters: Add any special instructions for the solution.

Done!

We can quickly see that our solution has been successfully imported.

Image description


Conclusion

Whether you go with the manual method, the Power Platform CLI, set up pipelines or use Power Automate flows, each way has its own benefits and can be adjusted to suit what you need.
I also would like to add, that regardless of your reasons (saving costs, reducing time or simplifying the process) each method has its pros and cons.
It’s all about picking the right tool for the job to make your solution management easier and more effective.

Happy automating!🫶

Top comments (0)