Skip to main content

Notifications

Power Automate - Using Flows
Unanswered

Flow to send records with different numbers of fields to Azure Cosmos DB

(0) ShareShare
ReportReport
Posted on by 2

If anyone can please help me with an issue building a flow to send a collectiion to Azure Cosmos DB.  The flow is giving me errors involving the final step and seems to be related to the partition key. The detailed current description and steps are below.

 

In the Powerapp I have an edit form that currently saves to to a relational SQL.  At the same time I Want to write each record update to a non-relational database to track the update history of all records. 

 

Step 1.  In the powerapp here is my code to send the data to a flow.  It combines the edit form and a UserID from another screen.  Then it converts the item to a JSON.  The last line is writing to the relational database and resetting the form.  This is an OnSelect feature of a button.

 

 ClearCollect(TranscribersAudit,TranscribersForm.Updates,{UserID:""});
 Patch(TranscribersAudit,Last(TranscribersAudit),             {UserID:TextInputUserName.Text});NoSQL.Run(JSON(TranscribersAudit,JSONFormat.IgnoreBinaryData));

SubmitForm(TranscribersForm);Refresh(Transcribers);

 

Step 2.   The flow receives the object, parses it as a JSON, and then goes to Azure Cosmos DB Create or update document connector.  I can actually pass straight from the powerapp to Azure Cosmos DB with or without a parse JSON just using the "body" of the powerapp connector.  I assume I can since I convert to JSON in the powerapp this works fine.    

 

RWoodward_0-1628780360735.png

RWoodward_1-1628780411062.png

RWoodward_3-1628780578108.png

 

 

The error I get is Message: {"Errors":["The partition key supplied in x-ms-partitionkey header has fewer components than defined in the the collection."]}.  

I have tried several inputs for the partiton key.  My container partition key is "/UserID" in Azure cosmos and my intent is to have a user ID in every record even though the number of elements in a record will change depending on the edit form I am sending from the powerapp.  Hence the {} in my parse JSON Schema.

 

If someone could help me with my flow to understand the syntax needed from the partition key.  I'm assuming I need to pass the User ID from my ParseJSON step with a statement to extract the value from {"UserID":""}

 

 

 

 

  • Zap1798 Profile Picture
    Zap1798 8 on at
    Re: Flow to send records with different numbers of fields to Azure Cosmos DB

    I actually found the fix. Try using the newer version of the Create or Update Document action (V2). It worked for me as I supposed the older version was outdated. 

  • RW-31071650-0 Profile Picture
    RW-31071650-0 2 on at
    Re: Flow to send records with different numbers of fields to Azure Cosmos DB

    No on has responded yet. I also checked with Microsoft support and they couldn’t help me. 

  • Zap1798 Profile Picture
    Zap1798 8 on at
    Re: Flow to send records with different numbers of fields to Azure Cosmos DB

    I'm having this issue also. Have you found a fix?

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,508

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,839

Leaderboard

Featured topics

Restore a deleted flow