Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

Handling Duplicate Connection References when Copying Flows

(0) ShareShare
ReportReport
Posted on by 42

Problem: The connectionReferences array can sometimes have duplicate values. The Create Flow and Update Flow actions cannot handle these duplicates, even though they are needed for correct functioning.

Background: Our organization is building an automated system to backup, restore and move around flows to help with maintaining production and development environments. To copy a flow to somewhere else we pull the flow data, parse the connectionReferences data and map it to the new environment, and then use the Create New Flow / Update Flow actions as appropriate.

Detail: Below is an example of the connectionReferences component of an in operations flow.

 

 "connectionReferences": [
 {
 "connectionName": "befd187677324f96893626c4696fbce7",
 "displayName": "SQL Server",
 "id": "/providers/Microsoft.PowerApps/apis/shared_sql"
 },
 {
 "connectionName": "befd187677324f96893626c4696fbce7",
 "displayName": "SQL Server",
 "id": "/providers/Microsoft.PowerApps/apis/shared_sql"
 }
 ]

 

We can see that it is duplicated. If this array (appropriately parsed) is fed into a New Flow / Update Flow action, it will throw an error complaining of the duplication. (see below)

Screenshot_7.png

 

Can not add property shared_sql to Newtonsoft.Json.Linq.JObject. Property with the same name already exists on object.
 at Newtonsoft.Json.Linq.JObject.ValidateToken(JToken o, JToken existing)
 at Newtonsoft.Json.Linq.JContainer.InsertItem(Int32 index, JToken item, Boolean skipParentCheck)
 at Newtonsoft.Json.Linq.JContainer.AddInternal(Int32 index, Object content, Boolean skipParentCheck)

 

If the duplication is removed, some of the actions in the flow will be missing their associated connection.

In this example, examining the flow code, it can be seen that Power Automate is maintaining two separate connection objects - shared_sql_1 and shared_sql. See the installedConnectionReferences property below.

 

 "installedConnectionReferences": {
 "shared_sql": {
 "connectionName": "befd187677324f96893626c4696fbce7",
 "source": "Embedded",
 "id": "/providers/Microsoft.PowerApps/apis/shared_sql",
 ....blah blah blah....
 },
 "shared_sql_1": {
 "connectionName": "befd187677324f96893626c4696fbce7",
 "source": "Embedded",
 "id": "/providers/Microsoft.PowerApps/apis/shared_sql",
 ....blah blah blah....
 }
 }

 

If this was a one off, it wouldn't be a problem. However there are large numbers of flows in our organisation which can have these duplicates.

Without a solution there is no reliable way to copy, move, update, backup, or restore flows in an automated fashion.

  • Verified answer
    Ana Almeida Profile Picture
    on at
    Re: Handling Duplicate Connection References when Copying Flows

    Hello, 

     

    The connection references are a separate component and should be used in the context of solutions at the moment. If you don't use solutions the behavior can be unexpected.

    In the case you want to export a subset of flows, you can create a solution just for them.

    It is important to mention, the Connection References is a Preview, if there is specific scenario in which this doesn't serve the purpose then it is best to open a case and describe the situation.

     

    To know more, how to work with solutions with using Microsoft Power Platform: https://docs.microsoft.com/en-us/power-platform/alm/

     

    Ana Almeida | Power Platform Support Engineer

  • Cazzym Profile Picture
    42 on at
    Re: Handling Duplicate Connection References when Copying Flows

    @analmei - The issue with using solutions is we lose the granularity of being able to move a single flow at a time, without impacting on other flows. Not all features in flow such as manual triggers work the same in solutions either.

     

    If there is a way to export only a subset of flows from a solution into another solution while keeping the existing flows that might be of help, but previously we judged solutions an inpractical solution to our needs.

  • Ana Almeida Profile Picture
    on at
    Re: Handling Duplicate Connection References when Copying Flows

    Hello, 

    I believe the best way to avoid this issue is start using a new feature called solution-aware flow, the ideia is to move the flows inside a solution and not just the Flow definition. 

     

    Please let me know if I was able to unblock you. 

    Ana Almeida | Power Platform Support Engineer

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow