cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Query Documents from Azure Cosmos DB only returns on item

Hello,

 

I have a Flow retrieving data from Cosmos DB - if I run the below query in the Data Explorer of Azure, it returns two items:

SELECT * FROM c WHERE c.OrderID in ("123","456")

If I run the same query using Query Documents in Flow, it only returns 1 item:

image.png

 

I have tested this with various Order ID collections - sometimes providing 10 or 20 in the IN ("....", "...") statement and sometimes the Query Documents returns 2 or 3 items, but never the full amount. 

 

Appreciate this is a bit vague, but any idea what's going on and what could be the issue? 

 

Thank you,

Manuela

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Automate Staff Audrie-MSFT
Power Automate Staff

Re: Query Documents from Azure Cosmos DB only returns on item

I got quite a few eyes on this for you, and ended up with the following suggestion. Please check to see if this works, if so, you may mark this as an acceptable solution.

 

Thank you for your patience as we investigated,

Audrie

 

Recommendation:

There is ‘x-ms-continuation’ in the response of the operation. This string token is returned for queries if there are more results to be read. You may retrieve the next page of results by resubmitting the same request again with the ‘x-ms-continuation’ parameter set to this value (see red bordored area in the screenshot below).

 

x-screenshot.jpg

 

I also found this blog on the topic here:

https://h-savran.blogspot.com/2019/04/introduction-to-continuation-tokens-in.html

View solution in original post

5 REPLIES 5
Super User
Super User

Re: Query Documents from Azure Cosmos DB only returns on item

The query you're using within Flow probably has a formatting issue. As the Azure CosmosDB Connector documentation points out, the query parameter needs to be in string format. You may need to perform a convert to string expression - as it seems that only the first number in your query is returning.

If you provide us a detailed/expanded screenshot of your Flow, and any errors your Flow has we may be able to provide further assistance. 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Community Support Team
Community Support Team

Re: Query Documents from Azure Cosmos DB only returns on item

Hi @Anonymous ,

 

I was wondering if there would be a non-existent situation in OrderID you configured.

You could try to test each ID individually to get the expected items.

Use array variables to store these OrderIDs, then traverse the array, use Apply to each to query each ID to see if it can get the expected item.

Please take a try.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Re: Query Documents from Azure Cosmos DB only returns on item

Hello,

 

thank you for your reply! I have tried running the queries individually and all OrderIDs exist, I tried both IN and = on the query for an individual Order ID and it returned a record for all IDs that I tried to use in the concatenated IN. I also tried changing the IN statement to an Order ID = ... OR Order ID = ... and that didn't work either, only returning a subset.

SELECT c.SegmentDetails, c.Fulfillment , c.Seat, c.OrderDetails, c.Tickets, c.FarePrice  FROM c
WHERE c.OrderID IN ("individual number")

and

SELECT c.SegmentDetails, c.Fulfillment , c.Seat, c.OrderDetails, c.Tickets, c.FarePrice  FROM c
WHERE c.OrderID = "individual number"

It's also not a case of it always just returning 1 record, on the below query I'm passing in about 10 Order IDs and the action returns 2 items, despite all 10 existing. 

image.png

 

Here's the action, the parameters get parsed in from PowerApps, but even if I hard code them directly in the query the result stays the same. 

image.png

Highlighted
Power Automate Staff Audrie-MSFT
Power Automate Staff

Re: Query Documents from Azure Cosmos DB only returns on item

I got quite a few eyes on this for you, and ended up with the following suggestion. Please check to see if this works, if so, you may mark this as an acceptable solution.

 

Thank you for your patience as we investigated,

Audrie

 

Recommendation:

There is ‘x-ms-continuation’ in the response of the operation. This string token is returned for queries if there are more results to be read. You may retrieve the next page of results by resubmitting the same request again with the ‘x-ms-continuation’ parameter set to this value (see red bordored area in the screenshot below).

 

x-screenshot.jpg

 

I also found this blog on the topic here:

https://h-savran.blogspot.com/2019/04/introduction-to-continuation-tokens-in.html

View solution in original post

Anonymous
Not applicable

Re: Query Documents from Azure Cosmos DB only returns on item

Thank you, Audrie! Just tested and this is working - that's great news! 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Users Online
Currently online: 449 members 5,425 guests
Please welcome our newest community members: