Query from logic apps is not searching across all partitions in CosmosDB when the partition key value field is empty

Viewed 50

The query from logic apps is not searching across all partitions in CosmosDB when the partition key value field is empty. When the exact same query is run from data explorer all partitions are queried and all expected data is returned. When the query is run from logic apps using log analytics I can see that a query is only being run for 1 partition range, and not all the expected results are returned. (some are, from the partitions that were hit)

From the docs for partition key value: Value must be provided according to its type ("string", 42, 0.5). If empty, all partitions will be used to search for documents.

Expected function would be logic apps Query documents V5 connector to return the same results from a SQL query as run in CosmosDB data explorer enter image description here

1 Answers

Query documents v5 can return an empty array in response to a query in CosmosDB, but the intended behaviour is for the user to check if the response has a continuation token, implying the query should be run again, passing in the continuation token as a header for the new request. This needs to be done to retrieve all the data.

Copy pasting a comment from another thread:

When executing queries using the REST API, make sure you are consuming and verifying the x-ms-continuation header. Reference: https://docs.microsoft.com/rest/api/cosmos-db/common-cosmosdb-rest-response-headers

You can iterate (send more requests) until the Continuation Token is not being returned in the response.

Related