Creating Junction object record in Salesforce

I have a csv file which has Account, Contact and Account Contact Relationship data.
Account is parent to Contact and Relationship,
Contact is parent to Relationship.

In my pipeline I need to first insert Account, then Contact and related the Contact with Account → This part is done.

Once Account and contact are inserted, I need to create a junction object record which will be stored in the object Account contact relationship.

As the data can already exist in the system for relationship, I need to perform an upsert operation.

If anyone has created a pipeline related to this, your help would be much appreciated.

Thanks in advance!