question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Assigning the PartitionKey

See original GitHub issue

Hi

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

image

Probably I am missing something I would be so glad if you could help, please.

Thank you

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
afacanermancommented, Dec 16, 2020

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.

0reactions
IEvangelistcommented, Mar 2, 2021

There is no reason to implement your own IItem, in this case just use the provided Item which already exposes the functionality you’re looking for and override the Item.GetPartitionKeyValue().

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found