How to export and import solutions using flows in Power Automate

Export and import Solutions

How to export and import solutions using flows in Power Automate

By:

Date:

Have you ever wanted to export and import solutions using a flow? In this post all you need to know to get started.

Perform an unbound action

First I want to have a look at two actions available in the Microsoft Dataverse connector.

  • Perform a bound action
  • Perform an unbound action
How to export and import solutions using flows in Power Automate

A bound action is connected to a table in Microsoft Dataverse

An unbound action is not related to a table in Microsoft Dataverse. .

Today it is the unbound actions that I’m going to need.

Perform an unbound action

In the perform an unbound action you will find many options.

The documentation is less than helpful.

How to export and import solutions using flows in Power Automate

Export and import solutions

To export and import solutions you can select Export Solution from the Action name drop down and a scary form will appear.

Export and Import solutions

Note that you might want to review the export settings, as you might want to export your solutions as managed solutions rather than unmanaged solutions.

And when we run this flow a solution file content is created. within 16 seconds. Have you seen an export happen within 16 seconds lately?

How to export and import solutions using flows in Power Automate

Now we can create a file using this exported content.

To get to the content the following expression is needed:

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

This could for example create a file in SharePoint.

Just imagine for one moment, you could create a regular export of all your solutions and create a backup of them in SharePoint, or Devops or wherever you like.

How to export and import solutions using flows in Power Automate

Import a solution using a flow

Now that we have a valid export, we might want to import the solution.

You can now supply the File content directly from the import, however, you would be more likely to import the solution in a different environment, hence using SharePoint to store the expert file might make sense.

How to export and import solutions using flows in Power Automate

Do however remmeebr to supply the ImportjobID, otherwise you will get the following error:

An error occurred while validating input parameters: Microsoft.OData.ODataException: One or more parameters of the operation ‘ImportSolution’ are missing from the request payload. The missing parameters are: ImportJobId.
at Microsoft.OData.ODataParameterReaderCore.EnterScope(ODataParameterReaderState state, String name, Object value)
at Microsoft.OData.JsonLight.ODataJsonLightParameterDeserializer.ReadNextParameter(PropertyAndAnnotationCollector propertyAndAnnotationCollector)
at Microsoft.OData.ODataParameterReaderCore.ReadImplementation()
at Microsoft.OData.ODataParameterReaderCore.InterceptException[T](Func`1 action)
at Microsoft.Crm.Extensibility.ODataV4.CrmODataActionPayloadDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)
at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)

The JobId has to be a UUID.

What is a UUID???

Well, all that is needed is a GUID. so we can use the guid() function to generate a unique id for our export and import of solutions

How to export and import solutions using flows in Power Automate

And when we review the installed solutions, we can see that our solution has been imported successfully. In only about 30 seconds.

How to export and import solutions using flows in Power Automate

So importing and exporting solutions using flows seems to be a lot faster than doing this manually. And it isn’t a bad idea to put a bit of a process ( approval etc) around our export and import solutions process anyway.

Is your business still running on paper trails, sprawling Excel files, or ageing Access databases? There’s a better way — and I can show you exactly what it looks like. I’m the Technical Director of Vantage 365, a Microsoft solutions consultancy working with clients across the UK, the Netherlands, and worldwide. For over 30 years I’ve been turning messy, manual business processes into clean, automated systems that save time, reduce errors, and give teams the visibility they need to make better decisions. SharePains is not just any blog run by a Microsoft MVP. Have you ever used Try-Catch in Power Automate? The original post about Try-Catch in Power Automate can still be found on this site, https://staging.sharepains.com/2018/02/07/try-catch-finally-in-power-automate-flow/ Or have you ever used the Pieter’s method to avoid variables and speed up your flows? https://staging.sharepains.com/2020/03/11/pieters-method-for-advanced-in-flows/ You can contact me using contact@staging.sharepains.com

19 responses to “How to export and import solutions using flows in Power Automate”

  1. nigelpwordpress Avatar

    Hi Pieter
    Is there a way of exporting and Importing a Canvas PowerApp using PowerAutomate Flow ?
    Or should I just put them into solutions and export them and Import then using this technique ?
    Regards
    Nigel

  2. Lawrence Avatar
    Lawrence

    Hi,

    Tried this regarding the export solution step. It works for a blank solution but not one containing apps / flows inside of Dataverse for Teams. Simply says the name cannot be found, I’ve tried all names I can see including the one listed without spaces (unique name). Any ideas?

    1. Pieter Veenstra Avatar

      I haven’t tried this with Dataverse for Teams.

  3. Christian Pospiech Avatar
    Christian Pospiech

    Help please, how to importSolution when i get zip file from sharepoint ? What formula a need to put in CustomizationFile ?

    1. Pieter Veenstra Avatar

      So when you read the file from sharepoint using a get file content, you will need to use the base64 functions to convert the content. In the post you can see an example of the reverse conversion.

      1. Ibrahim Abdelhamed Avatar
        Ibrahim Abdelhamed

        Please Can you tell me What is formula I need to put in [CustomizationFile] input in the import flow that I have to made in the production environment ???

      2. Pieter Veenstra Avatar

        That is the CustomizationFile that comes out of the Export action.

      3. Ibrahim Abdelhamed Avatar
        Ibrahim Abdelhamed

        I can’t access or get this file since I separate the import flow in the production environment, any clarification please.

      4. Pieter Veenstra Avatar

        So you could get the export flow to save the file somewhere and then get the import flow to first read the content before using it in the action that does the import.

  4. tsa Avatar
    tsa

    is there a way to import a solution to dataverse for teams via dlows?

    1. Pieter Veenstra Avatar

      I haven’t tried it, but as you can create solutions by going to the solutions URL and replace the GUID of the environment. You should also be able to use the export/import as described in this post.

  5. Emilio Avatar
    Emilio

    How can we import a solution and set all flows within off ?

    1. Pieter Veenstra Avatar

      You could pause all flows in a similar way as described in this post:

      https://staging.sharepains.com/2020/12/02/re-enable-flows-power-automate/

      So if you had one scheduled flow that starts on deployment that disables all flows then that might work.

  6. User1 Avatar
    User1

    Is there anyway to automate the connection refresh..?

    1. Pieter Veenstra Avatar
  7. vinayak Avatar
    vinayak

    Are we Creating two different flows here? The first export in one environment and import in another environment(target).
    In that case, does adding the file to sharepoint doc library trigger the second flow?
    Thanks!

    1. Pieter Veenstra Avatar

      Yes, it could be two separate flows.

  8. Anand Avatar
    Anand

    During Import setting CustomizationFile = ExportSolutoinFile from output of Export Solution , not importing all the solution components.

    Ex”: I had the setting definition “Hide the nav bar” in my solution in source environment. Exported the solution and created the file .zip in Share point worked. Manually verified that .zip includes the setting definition.

    After importing the solution to target environment ,the solution is empty.

    1. Pieter Veenstra Avatar

      Does the import work successfully when you import it using the Power Platform UI?

Leave a Reply

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