Scotty H
Scotty H

Reputation: 6714

Azure Cosmos DB SDK v3 query for multiple documents fails: Gateway Failed to Retrieve Query Plan

Using the Cosmos DB SQL API in the Cosmos SDK v3, I'm attempting to query the projects container, which has an /organization partition key.


var cosmosDb = await Storage.GetCosmosDb();
var queryDefinition = new QueryDefinition($"SELECT * FROM projects project WHERE project.organization = '{CurrentUser.Organization}'");
var queryRequestOptions = new QueryRequestOptions
{
    PartitionKey = new PartitionKey("organization"),
};
var projectsQuery = cosmosDb.Containers[typeof(Project)]
    .GetItemQueryIterator<Project>(queryDefinition, null, queryRequestOptions);
var projects = new List<Project>();
while (projectsQuery.HasMoreResults)
{
    projects.AddRange(await projectsQuery.ReadNextAsync());
}

The result of this is an error:

Response status code does not indicate success: 400 Substatus: 0 Reason: (Response status code does not indicate success: 400 Substatus: 0 Reason: (Gateway Failed to Retrieve Query Plan: Unknown QueryFeatures: NonValueAggregateActivityId: ceb5a509-36a0-4e20-87cd-32b6425dc757, Microsoft.Azure.Documents.Common/2.4.0.0, Windows/10.0.18362 cosmos-netstandard-sdk/3.2.1).).

Am I missing something obvious? What does this error mean?

Upvotes: 4

Views: 3571

Answers (3)

Mehdi Benmoha
Mehdi Benmoha

Reputation: 3935

For me, it was the scaling mode that was Manual in a collection, updated it to Autoscale, like the container setting and it worked.

Upvotes: 0

Benjamin Talmard
Benjamin Talmard

Reputation: 1820

Updating the CosmosDB Emulator to the last version should fix the issue.

I had the issue with 2.4.5 and don't have it anymore with 2.5.7.

Upvotes: 2

Matias Quaranta
Matias Quaranta

Reputation: 15603

This has been detected as an issue on SDK 3.2.0 when running in x86: https://github.com/Azure/azure-cosmos-dotnet-v3/issues/856

Current workaround is to run in x64 when working with the Emulator.

It should be fixed in the upcoming 3.2.1 release.

Upvotes: 1

Related Questions