[Question] Assigning the PartitionKey
See original GitHub issueHi
I am trying to use this package configuring the custom partition key (/userIdentifier) instead of /Id, but I am getting an error from cosmos client as below
System.ArgumentException: The requested partition key path '/id' does not match existing Container 'VideoElapsedTimeData' with partition key path '/userIdentifier' (Parameter 'PartitionKey')
public class VideoElapsedTimeData : Item
{
[JsonProperty("userIdentifier")] public string UserIdentifier { get; set; }
[JsonProperty("consumedTimeInMs")] public double ConsumedTimeInMs { get; set; }
[JsonProperty("metadata")] public string Metadata { get; set; } = string.Empty;
[JsonProperty("videoType")] public string VideoType { get; set; } = string.Empty;
[JsonProperty("viewedPercentage")] public double ViewedPercentage { get; set; }
[JsonProperty("trimInMs")] public double TrimInMs { get; set; }
[JsonProperty("trimOutMs")] public double TrimOutMs { get; set; }
[JsonProperty("timestamp")] public DateTimeOffset Timestamp { get; set; } = DateTimeOffset.UtcNow;
[JsonProperty("videoId")] public string VideoId { get; set; }
protected override string GetPartitionKeyValue() => UserIdentifier;
}
My container partition key set as /userIdentifier

Probably I am missing something I would be so glad if you could help, please.
Thank you
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Assigning the same partition key to all items in a ...
Say you require 10,000 WCU for the GSI. You can assign each item's GSI PK value to a random value-{x} where x is...
Read more >Partitioning and horizontal scaling - Azure Cosmos DB
Learn about partitioning, logical, physical partitions in Azure Cosmos DB, best practices when choosing a partition key, and how to manage ...
Read more >What are the Cons of making Primary key or assigning ...
I would like to assign unique GUID as value to every partition key property For that container. Now my question is,. What are...
Read more >Microsoft Azure - Choosing a Partition Key in Cosmos DB
A partition key can have values of string or numeric types, and once you've created a key for a container, you can't change...
Read more >Best practices for designing and using partition keys ...
Generally speaking, you should design your application for uniform activity across all logical partition keys in the table and its secondary indexes. You...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Yes, it’s working now. I have managed to solve it only after focusing on the source documentation. Would be nice to have an example though. Great job, thanks.
There is no reason to implement your own
IItem, in this case just use the providedItemwhich already exposes the functionality you’re looking for and override theItem.GetPartitionKeyValue().