Using Power Automate Flow for Exporting and Importing Solutions
Tags: powerplatform, powerautomate, powerfuldevs, powerapps
Published: 2024-06-14 15:43:23

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/etqe0fl4huvq94zx9izw.png)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/usk5y4n0jatuvxxjhxol.png)


## Solution backup
I store the solution versions in a SharePoint library and from there I can trigger the import/export process. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oivrubkzaccqf6s6lfa3.png)

To do so use the following expression to create a file with the exported content:
```
base64ToBinary(Body('Perform_an_unbound_action')?['ExportSolutionFile'])

```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nhkz2ly5p8qost56xned.png)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rm6z2lst6nkg4tywnus6.png)



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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q8eq3ashgcmwx18optph.png)



- **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']

```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ngamjpg4k4ygvzr309y.png)
- **ImportJobId:** This is a unique ID for the import task, so we can  generate a uniqueID for our export/import.

```
guid()
```
- **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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ayongdoh0sjwsh5swbhd.png)


---

## 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!🫶