Botbuilder-dotnet: CosmosDB: Cross partition query is required but disabled.

Created on 18 Dec 2018  路  6Comments  路  Source: microsoft/botbuilder-dotnet

Github issues should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.

Version

4.2.0

Describe the bug

There is an exception when the bot makes requests to CosmosDb storage. It looks like some config parameter is missed. It requires to enable cross-partition query, but the configuration of CosmosDbStorage class doesn't allow it.

To Reproduce

Steps to reproduce the behavior:

  1. Create and configure CosmosDB connection using the guide

```C#
IStorage dataStore = new CosmosDbStorage(new CosmosDbStorageOptions
{
AuthKey = "xxx",
CosmosDBEndpoint = new Uri("https://xxx.documents.azure.com:443/"),
DatabaseId = "db-test",
CollectionId = "state-collection-test"
});

// Usage in ConversationState, UserState
````

  1. Run the project
  2. Do something which makes query to CosmosDB
  3. See 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: bc813a2a-de89-4b1d-809f-82fef8e2d5da, Microsoft.Azure.Documents.Common/2.1.0.0, Windows/10.0.17134 documentdb-netcore-sdk/2.1.2

Additional context

Enabling or disabling cross partition query in the CosmosDB settings (using Azure, data explorer) doesn't resolve the problem.

[bug]

4.3 bug triaged

Most helpful comment

I have also run into this problem. This is fairly fundamental to using CosmosDB. Furthermore this portal now says "We are planning to deprecate ability to create non-partitioned containers, as they do not allow you to scale elastically."

Would we be able to get a property to set that could enable it?

  • Update *
    Turns out if you create your collection up front and specify "id" as your partition key then it works fine. Probably with noting this somewhere for future reference.

All 6 comments

I have also run into this problem. This is fairly fundamental to using CosmosDB. Furthermore this portal now says "We are planning to deprecate ability to create non-partitioned containers, as they do not allow you to scale elastically."

Would we be able to get a property to set that could enable it?

  • Update *
    Turns out if you create your collection up front and specify "id" as your partition key then it works fine. Probably with noting this somewhere for future reference.

I've got a working implementation in Node with written and passing tests. I'm hoping to get to a dotnet/C# version, but I'm still new to C# and am busy working on support tickets, so somebody else might be able to implement faster than I.

Is it available to use CosmosDb in 4.2 version? Or will it be fixed in 4.3?

You can use CosmosDB without partitions currently. Create the CosmosDB resource in Azure and let the bot create database and collection (the Azure Portal requires you set a partition, but the bot can make a non-partitioned collection).

Partitioning is currently slated to be supported in 4.4. See DCR: https://github.com/Microsoft/BotBuilder/issues/5107

The documentation here describes how to create the collections states that you should set the partition key as "/id" did you try that?

Also I just ran through a scenario _where I didn't have the collection created_ instead I let the run-time create the collection on the fly. I'm not sure I'd recommend this approach for CosmosDB however I wanted to check whether it was working. So it appeared to work fine, I just gave the name of the collection and did a write and read and there was no exception.

@mdrichardson example is interesting, and that would give you some notional partition behavior. However, I would have thought in many real world scenarios you would be looking to use something dynamic from the data itself rather than a statically configured key.

Anyhow I'm closing this issue now because I can't seem to reproduce that exception. Perhaps I'm doing something you're not? Anyhow if you can provide exactly the steps I can try again. One thing is I was instantiating and using the CosmosDbStorage component standalone, but that shouldn't have made any difference.

Was this page helpful?
0 / 5 - 0 ratings