I have an Azure Function with a Cosmos DB trigger configured to auto-create a lease collection on-demand, I get the following error when running against a Cosmos DB with throughput configured at database level
[30/11/2018 23:33:04] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.Foo'. Microsoft.Azure.WebJobs.Extensions.CosmosDB: Cannot create Collection Information for X in database Y with lease leases in database Y : Shared throughput collection should have a partition key
Works absolutely fine when the throughput is solely configured at container level. Also tried manually creating a lease collection and setting id
as the partition key (given from my other DB it looked like all a lease has was an id
/ ttl
) but then it complains about the PK not being provided.
Any ideas?
Most small containers in Azure Cosmos DB only require one or two physical partitions. If your container could grow to more than a few physical partitions, then you should make sure you pick a partition key that minimizes cross-partition queries.
Azure Cosmos DB is highly scalable And that is because it uses a partitioning system to scale, which consists of physical and logical partitions. To optimize the scalability and performance of Azure Cosmos DB, you need to choose the right partition key for your container.
In this lab, you will create multiple Azure Cosmos DB containers. Some of the containers will be unlimited and configured with a partition key, while others will be fixed-sized. You will then use the SQL API and Java Async SDK to query specific containers using a single partition key or across multiple partition keys.
Navigate to your Azure Cosmos DB account and open the Data Explorer tab. Select New Container. Enter a name for your database, container, and a partition key. Under database or container throughput, select the Autoscale option, and set the maximum throughput (RU/s) that you want the database or container to scale to.
EDIT : this is now supported with the version 3.0.3 of the Microsoft.Azure.WebJobs.Extensions.CosmosDB
NuGet package. Tested and works fine with Azure Functions 2.0.
James, this is being supported soon, the PR is already being reviewed to add Partitioned Lease Collections, please see https://github.com/Azure/azure-webjobs-sdk-extensions/pull/520
At this moment the version of the Change Feed Processor library used in Azure Functions does not support partitioned lease collections, the latest version does, so part of that PR is updating the library dependency.
This is mostly common on Shared RU at the Database level.
Please take a look at the Function Output - configuration Please note that this is for version 2.0 of Azure Function bindings for Cosmos DB.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With