Implementing Change Feeds for Serverless CosmosDB with Serverless Azure Functions?

Siegfried Heintze 1,881 Reputation points
2022-01-12T20:08:04.387+00:00

Can someone point me to some discussions of how to implement a Change Feed for a serverless Cosmos database? I've been studying Mark Brown's CosmicWorks and Jeremy Likness's PlanetaryDocs

  1. Let's assume that I decided on an Azure function for implementing a change feed... After studying Mark's code I see the change feed console mode program is running continuously. So if I use an Azure function (functions-bindings-cosmosdb-v2-trigger) code, would I benefit from the serverless feature of Azure functions? It looks like that trigger is running continuously just like the process is in Mark's sample code. Can I conclude that Azure would have to continually charge me Azure Function computes even when my serverless Cosmos DB is idle (and charging me very little) for long periods of time?
  2. Assuming I'm correct and that the Azure function would be continually running up my Azure bill even when my serverless cosmosDB was idle for long periods of time, why would anyone saving money with a serverless Cosmos DB prefer a change feed implemented as an Azure Function? Of course, latency could be an issue. Any other reasons?
  3. More specifically: what is the merit of implementing a change feed by calling GetChangeFeedProcessorBuilder (line 38) instead of just making a REST or gRPC call to an Azure Function or a ACI or Kubernetes service whenever we make a change to the CosmosDB database? If latency is not a problem, then we have the option of making the the azure function, ACI or Kubernetes service serverless.

Thanks!

Siegfried

Sun Jan 15 2022 Update:
Let me try to clarify bullets 2 & 3: If I use C# code at functions-bindings-cosmosdb-v2-trigger to implement a change feed (for serverless CosmosDB that is mostly idle) in a serverless Azure Function, will the azure function be running continuously (charging me for computes) listening for events? If so, what might be a cheaper alternative strategy to exploit the some serverless feature (serverless Azure Functions or serverless kubenetes pod maybe)?

Tue Feb 01 2022 update:
I think I found the answer to my question here where it says: The following example shows a C# function that is invoked when there are inserts or updates in the specified database and collection.. I think this means that there are no computes charged when the cosmosdb is idle.

I'm still not clear on consumption mode however... Is this a option I set when creating the Azure Function in the azure portal? I could not find a check box for this. See my reply below where I explained that bing/google searched for this.

The Feb 03 2022 Update:
Looks like I was confused because the azure.portal uses the term "serverless" instead of "consumption plan" and apparently these are synonymous.. I'll mark this question as answered.

Thanks

Siegfried

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,887 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,611 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,073 questions
0 comments No comments
{count} votes

Accepted answer
  1. Mark Brown - MSFT 2,766 Reputation points Microsoft Employee
    2022-01-14T19:33:05.807+00:00

    You can use Azure Functions in consumption mode but if you do we recommend you use Gateway mode vs direct mode as consumption mode has a limited number of sockets. Keep in mind too that these are very small machines. Not best for doing computationally heavy work. Also can experience cold starts when they are recycled so good to understand their behavior during cold starts. Other than that should be no problem using Consumption Functions with Cosmos Serverless.

    Regarding #3, I'm not sure what you are asking. The code there is how you create the delegate that gets called so you can respond to changes in data in Cosmos DB.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.