4
votes

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?

3
Which SDK version are you using and are you running against a live account or the emulator?Matias Quaranta
@MatiasQuaranta I'm using v3 and running against the emulator.Scotty H
It seems like your Emulator might be old, can you try uninstalling and downloading the latest version?Matias Quaranta
@MatiasQuaranta updated from 2.4.5 to 2.5.6 just now, and I still have that error. Restarted the computer. Any other ideas?Scotty H
This problem seems to be isolated to querying. I am able to insert.Scotty H

3 Answers

2
votes

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.

1
votes

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.

0
votes

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