Shared throughput collection should have a partition keyActivityId

Thangavel Daniel Tamilarasan 271 Reputation points
2022-11-28T12:40:24.493+00:00

Hi,

I have a Cosmos dB database with shared throughput, it contains a container with PartitionKey. The throughput is set to Autoscale.

Then from a function app I tried to insert items into the container which then throws the below error.

[Error] Shared throughput collection should have a partition keyActivityId: 6ccfd696-5f80-45fe-808f-54aaea914908, Microsoft.Azure.Documents.Common/2.14.0, Windows/10.0.14393 documentdb-netcore-sdk/2.13.1

Function app is using the following nuget packages.
264758-skarmbild-2022-11-28-133839.jpg

Appreciate any help to fix this.

Thanks,
Daniel

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,620 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,531 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Thangavel Daniel Tamilarasan 271 Reputation points
    2022-11-29T11:40:15.343+00:00

    Hi,
    Yes, I use the output binding, yes, the Partition Key attribute is set.

    I resolved the issue - by manually creating the lease container 'Online_Event'. Please refer the blow. Then the problem disappeared. Though CreateIfNotExists =true, the lease container was not created for some reason.

            [FunctionName("ArchiveFunction")]  
            public static async Task RunAsync([BlobTrigger("%BlobContainer%/{name}", Connection = "StorageConnection")] Stream myBlob, string name,  
                [CosmosDB(  
            databaseName: "PCArchive",  
            collectionName: "PCEvents",  
            ConnectionStringSetting = "CosmosDbConnectionString")]IAsyncCollector<dynamic> documentsOut, ILogger log,  
            [CosmosDB(  
            databaseName: "PCArchive",  
            collectionName: "Online_Event",  
            CreateIfNotExists =true,  
            ConnectionStringSetting = "CosmosDbConnectionString")]IAsyncCollector<dynamic> leaseSBOOut)  
            {