...

/

Connecting Azure Functions to Cosmos DB

Connecting Azure Functions to Cosmos DB

Learn how Cosmos DB integrates with Azure Functions, from triggers to bindings.

Azure Functions

Cosmos DB works exceptionally well in a serverless architecture thanks to its change feed and binding for Azure Functions. In this lesson, we’ll see a realistic example of architecture and code for the following:

  • Triggers

  • Input binding

  • Output binding

Triggers

A trigger starts an Azure Function. For example, a trigger can be an HTTP request or a timer. In our case, we want to listen to container changes, and to do so, we need to use CosmosDBTrigger. The function is called automatically when documents change in a container.

The trigger requires some parameters to work:

  • databaseName ...