Power Automate: Cloning flows in same tenant pointing to separate sources
Tags: tutorial, powerautomate, flow, microsoft
Published: 2021-12-09 07:22:23

While developing solutions in PowerApps or Power Automate we would generally be doing development in the Default (Company) environment. There might be licensing costs associated with multiple environments and hence it may be an issue in getting separate development, QA or UAT environments. 

It can be thought of a scenario like having single sql-server with multiple copies of Database, one as Dev and other as QA. Similarly, in power automate we can clone a flow into multiple copies in each solution and name the flows accordingly.

Steps :
1.	Extract the Deployment package using the export option at a solution level: SolutionPackage_1_0_0_1.zip

2.	Unzip the package to local computer and the folder structure shall be as shown:


![Power Automate Package](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aka3b9j9zh41aubs1800.png)

3.	Delete the folder : environmentvariabledefinitions and its contents (includes sub-folders , json files)

4.	Navigate to the Workflows folder and you shall find a pre existing JSON file , copy the JSON file and paste it in the same folder location.


![Multiple JSON file copies](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0te5vvxfwqsvgrif2h8y.png)

5.	Rename the copied file by renaming the Flow Name as well replaced the existing GUID with a new GUID (the GUID in the file name should be in Upper Case)
You might use the following URL for GUID generation 
[GUID-Generator](https://www.guidgenerator.com/online-guid-generator.aspx)

6.	Modify the customizations.xml file in the location: SolutionPackage_1_0_0_1\customizations.xml

We shall modify the existing Workflows section, i.e will not be copying same section twice (copying over and modifying the copied section seems to be throwing errors) , but instead updating the existing section and the places to be modified are highlighted below (follow the instructions on the CASE (upper/lower) of the GUID as mentioned in the image below) :


![Modification to the JSON file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j6x2ng6vw5fjwmdr0to9.png)

Use the lower case GUID as and where applicable and can use the following online resource for the same :  
[CaseConverter](https://convertcase.net/)

7.	Next we shall modify the solution.xml at ~ \SolutionPackage_1_0_0_1\solution.xml

a.	Modify the version number 
<Version>1.0.0.2</Version>

b.	Update the existing RootComponent , (copying over and modifying the copied section seems to be throwing errors)


![Modification to the solution file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hu4r74q5wsk9l9k7uc5l.png)

c.	Remove the entries under: <MissingDependencies>     
 </MissingDependencies>

8.	Create a zip file maintaining the underlying folder structure to generate the updated deployment package

9.	Import the deployment package and you shall find the clones of your flow in the solution


![Multiple Clones Deployed](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kwyjgk2pzgrqfxo09vrw.png)

10.	Define separate environment variables in the solution.

11.	For each environment use the corresponding environment variables inside your flow. Disable the flows when not required or delete them as required independently.

This way we can reuse the same environment to point to separate share point locations simultaneously from the same solution.

[Reference](https://powerusers.microsoft.com/t5/Building-Flows/Copy-Duplicate-a-Flow-in-a-Solution/td-p/487483)