Serverless event-based architectures with Azure Cosmos DB and Azure Functions
Article
APPLIES TO:
NoSQL
Azure Functions provides the simplest way to connect to the change feed. You can create small reactive Azure Functions that will be automatically triggered on each new event in your Azure Cosmos DB container's change feed.
The Azure Functions trigger uses latest version change feed mode. Currently, the Azure Functions trigger for Azure Cosmos DB is supported for use with the API for NoSQL only.
Requirements
To implement a serverless event-based flow, you need:
The monitored container: The monitored container is the Azure Cosmos DB container being monitored, and it stores the data from which the change feed is generated. Any inserts, updates to the monitored container are reflected in the change feed of the container.
The lease container: The lease container maintains state across multiple and dynamic serverless Azure Function instances and enables dynamic scaling. You can create the lease container automatically with the Azure Functions trigger for Azure Cosmos DB. You can also create the lease container manually. To automatically create the lease container, set the CreateLeaseContainerIfNotExists flag in the configuration. Partitioned lease containers are required to have a /id partition key definition.
Create your Azure Functions trigger for Azure Cosmos DB
Creating your Azure Function with an Azure Functions trigger for Azure Cosmos DB is now supported across all Azure Functions IDE and CLI integrations: