Combining PowerAutomate and Dataflows for Migration of Dataverse Data

Following on from my Dataflow migration (and my inherent need to see if something was possible), I wanted to see if I could migrate Business Units from one Dataverse to another using PowerAutomate and relate them accordingly.

To accomplish this task, I made use of the “Get/Add Environment” actions in Power Automate.

(Sorry, I’m still using the v2 UX for Power Automate, because it is nicer to screenshot).

Get the Current Parent Business Unit

First thing I did was get the parent business unit from my DEV environment because that’s what ever sub-unit will be related to.

Get the Children Business Units

Just as easily, I retrieved all the business units in my TST that I wanted to migrate into DEV.

Putting it Altogether

Once I had those two groups, all I had to do was get the DEV ParentBusinessUnit, assign it to a variable, and then iterate over the new units I wanted to create, assigning them to the parent.

Now what I didn’t add, which I don’t think would be too hard, would be in the iteration of business units from TST, I might have to check if a Parent Unit exists that is not the root business unit, and if so use that as the parent (I hope it would be that easy and not have to get into some fancy recursion.

Refreshing a Dataflow from your Flow

The reason for the above was that I needed to find a way to migrate my business units since data flows could not accomplish this task. If you run into data that you can’t migrate with dataflows, the above is a nice pattern that lets you migrate some source/core data first, but still leverage the work you put into your dataflows by being able to call them after the fact from your PowerAutomate flow (or not if an error occurs).