Search code examples
c#azureazure-functionsazure-cosmosdbcosmosdbtrigger

Azure Cosmos Lease Container only creates one lease for whole container even though there are thousands of partitions


I have created an azure function that uses CosmosDBTrigger to monitor changes. Azure Function Setup

I added 120,000 items to the container very quickly and watched my azure function scale to 20 servers but there CPU was barely being utilized (except for one) 20 Servers, not using CPU enough

I checked my lease container and there was only two items, one being the lease and one being the .info enter image description here

Here is the settings for the lease container enter image description here

My partition in my container I am listening to is "ClientOrderId" so every order is in its own partition (write heavy). Why isn't my lease container distributing the leases so my azure functions can run in parallel?

Thanks in advance.


Solution

  • The number of leases is for the Physical Partitions, not Logical Partitions.

    See: https://learn.microsoft.com/azure/cosmos-db/partition-data