0
votes

I have one cosmos collection CompanyProfile where i have one Partition key Department. Now I have three different values Finance ,IT,HR .As per my understanding based on different values Cosmos will create logical partition .In that case we have three partition -Finance ,IT,HR .

I want to create different Azure Function consumer on those three logical partition keys. can you please help if its possible or not. If yes then please refer some document or example .

1
What have you tryed up to this point. You might want to have a look at How to askMathieu de Lorimier
Mathieu, Sorry for the confusion .i just want to know can we create different consumer on Cosmos db collection Logical Partition .As given above i have one collection and my partition key is department . now i might have couple of different values which is kind of logical partition inseide cosmos db.Victor Dey
@VictorDey Are you intended to have 3 different functions? Meaning different names and implementation?Kiryl Z

1 Answers

0
votes

As to my knowledge, CosmosDBTrigger doesn't allow to specify a partition key, so here are the options that I can think of-

  1. TimeTrigger and DocumentDB binding

DocumentDB input binding has a property that allows you to specify a partition key and sql query to retrieve the documents. The approach assumes that you'd be firing up your functions at some fixed intervals and reading the latest data out from the collection based on the last time that function has been triggered at.

Here is the list of all different parameters you could set up for the binding - Input configuration.

  1. Gateway and CosmosDBTrigger

The approach implies using CosmosDBTrigger with a dedicated Azure Function(Gateway) that will be called upon the changes in a given collection. The solely goal of that function would be to 'redirect' the incoming input based on the partition key toward more specific functions, like via http triggers or something.

For the sake of scalability, you could decouple Gateway and Specific Functions with storage queues.

  1. Separate service and Change Feed

Pretty much like a previous approach, but instead of implementing gateway as an Azure Function, you could have a service implemented in .NET running somewhere either in the cloud or on-prem. The SQL SDK for Azure Cosmos DB gives you all the power to read and manage a change feed, so that service will listen for whatever comes in the feed, and then distribute it across appropriate Azure Functions.

If you have multiple readers, you can use ChangeFeedOptions to distribute read load to different threads or different clients.