I need to create a collection in Azure's Cosmos MongoDB but with a partition/shard key as the required configuration is that the database will have a provisioned throughput (a set amount of RU's) and the collections in it will have a shared throughput.
The cluster's API is set to Cosmos DB Mongo API
- If i create the collection in the cosmos i have no issues with Insert/Delete, but if i create the collection using the code below i will get an error saying {"Command insert failed: document does not contain shard key."}
even though viewing the collection made in the portal and in the code look identical.
client.CreateDocumentCollectionAsync(database.SelfLink,
new DocumentCollection
{
Id = "CollectionName",
PartitionKey = new PartitionKeyDefinition { Paths = new Collection<string> { "/_id" } }
}).Wait();
I have talked to a microsoft representative but i get lacking "answers". He advised to use Mongo CSharp Driver
but it seems this driver is unable to define a partition key (which makes sense).
How can i create a collection with a partition key?
Thank you.