5

I'm using Azure Cosmos DB .NET SDK Version 3.0 and I want to create container programmatically without partition key. Is it possible? I always got error saying Value cannot be null. Parameter name: partitionKey

I use method CosmosContainers.CreateContainerIfNotExistsAsync

4
  • Hi,does my answer helps you? Commented Mar 21, 2019 at 1:15
  • Seems like it. As long as it is not a bad idea to have primary key as a partition key, it's okay. And cross-partition queries are still doable. Thanks for your effort! Commented Mar 21, 2019 at 13:19
  • Hi,if my answer is helpful, you could accept it for answer.Thanks a lot. Commented Mar 25, 2019 at 0:48
  • Done. Thank you! Commented Mar 25, 2019 at 9:31

1 Answer 1

7

Reproduce your issue on my side always.

enter image description here

Notice the exception is caused by below method:

enter image description here

Try to deserialize the dll source code and find the detailed logical code.

enter image description here

It seems we can't cross this judgement so far because cosmos db team is planning to deprecate ability to create non-partitioned containers, as they do not allow you to scale elastically.(Mentioned in my previous case:Is it still a good idea to create comos db collection without partition key?

But you still could create non-partitioned containers with DocumentDB .net package or REST API.

Sign up to request clarification or add additional context in comments.

3 Comments

Seems like it. As long as it is not a bad idea to have primary key as a partition key, it's okay. And cross-partition queries are still doable. Thanks for your effort!
@MisaKovar You're so kind, you could mark it for answer. Thanks a lot!
Done. Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.