Azure-docs: Cross Partition Query Error

Created on 28 Jul 2019  Â·  6Comments  Â·  Source: MicrosoftDocs/azure-docs

I've tried to run through this example a few times just to make sure I haven't missed a step. I'm using Visual Studio for Mac and when I try to run the app, I get the following error:

Cross partition query is required but disabled. Please set x-ms-documentdb-query-enablecrosspartition to true, specify x-ms-documentdb-partitionkey, or revise your query to avoid this exception.

ActivityId: c24d3f0a-304d-42a3-833a-4e2feb08addc, Microsoft.Azure.Documents.Common/2.5.1, Darwin/10.14 documentdb-netcore-sdk/1.9.1

Any suggestions?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 assigned-to-author cosmos-dsvc cosmosdb-sqsubsvc doc-bug triaged

All 6 comments

@sjbolinger Thanks for the question! We are investigating and will update you shortly.

I fixed the issue with two edits to the CosmostDBService.cs file, adding the EnableCrossPartitionQuery argument:

var todoQuery = docClient.CreateDocumentQuery(
UriFactory.CreateDocumentCollectionUri(databaseName, collectionName),
new FeedOptions { MaxItemCount = -1, EnableCrossPartitionQuery = true })
.Where(todo => todo.Completed == false)
.AsDocumentQuery();

var completedToDoQuery = docClient.CreateDocumentQuery(
UriFactory.CreateDocumentCollectionUri(databaseName, collectionName),
new FeedOptions { MaxItemCount = -1, EnableCrossPartitionQuery = true })
.Where(todo => todo.Completed == true)
.AsDocumentQuery();

@sjbolinger Thank you very much for posting the solution to this issue. I will have the content author review this and make an appropriate update to the sample solution. Thanks again.

@codemillmatt Looks like the customer identified an issue with this tutorial and wanted to bring this to your attention. Please let CXP know if there is a change you would like us to make. Thank you.

Fix merged into master of the azure sample. Thanks @SnehaGunda !!

Thank you @sjbolinger for finding it.

@sjbolinger in addition to the code sample, I made some fixes to the doc. We will now close this issues if there aren't further questions.

please-close

Was this page helpful?
0 / 5 - 0 ratings