Serverless Database Computing: Azure Cosmos DB Triggers and Azure Functions

Serverless computing is a relatively newer development in the cloud computing space. In the normal computing scenario, program code resides either on the server or the client. Serverless computing changes this paradigm, with stateless code, i.e. code that does not require any infrastructure.

Customers only have to pay for the compute resources used by the code during the short time that it takes for executing the code, (usually a few seconds or milliseconds) which is very cost effective. These code snippets that perform specific tasks are called functions.

Azure Functions is the serverless computing service on the Azure platform that provides Function as a Service (FAAS) feature to customers. Azure Functions is very tightly integrated with Azure Cosmos DB.

Cosmos DB triggers are procedural codes that run automatically when a database event such as insert, update or delete occurs.

 There are three ways in which Azure Functions can be used with Azure Cosmos DB for serverless computing:

  1. Cosmos DB Trigger: This option is for invoking an Azure Function based on changes in Cosmos DB container. When a change is made to a container in Cosmos DB, the Cosmos DB change feed stream is sent to the Cosmos DB trigger, the trigger then invokes the Azure function.
  1. Input Binding: Once input binding is created; Cosmos DB trigger can be used to invoke a function. When the function executes, data is read from Cosmos DB container.
  1. Output Binding: If a function is bound to an Azure Cosmos DB container using output binding, data is written to the container when the function executes.

Currently, only SQL API is supported for all three of the above options.

Reference: https://docs.microsoft.com/en-us/azure/cosmos-db/serverless-computing-database#why-choose-azure-functions-integration-for-serverless-computing

One thought on “Serverless Database Computing: Azure Cosmos DB Triggers and Azure Functions

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: