Shared throughput collection should have a partition keyActivityId

Thangavel Daniel Tamilarasan 271 Reputation points


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.

Appreciate any help to fix this.


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

    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.

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