Serverless apps using Azure Cosmos DB

Cosmos DB
Functions

Solution ideas

This article is a solution idea. If you'd like us to expand the content with more information, such as potential use cases, alternative services, implementation considerations, or pricing guidance, let us know by providing GitHub feedback.

You can use Azure Functions and Azure Cosmos DB to build globally distributed, scalable serverless applications.

Architecture

Architecture diagram that shows the functions that are triggered by an online order and a database change feed.

Download an SVG of this architecture.

Dataflow

  • A customer places an order in an e-commerce website.

  • The order triggers an instance of Functions. The function processes the customer's checkout and stores information about the order in Azure Cosmos DB.

  • The database insert operation triggers an Azure Cosmos DB change feed event.

  • Systems that subscribe to change feed events are notified.

  • The change feed notifications trigger Functions:

    • A function applies taxes to the order.
    • A function processes payment for the order.
    • A function fulfills the order.

Components

  • Functions is an event-driven serverless compute platform. With Functions, you can use triggers and bindings to integrate services at scale.
  • Azure Cosmos DB is a globally distributed, multi-model database. With Azure Cosmos DB, your solutions can elastically scale throughput and storage across any number of geographic regions.

Scenario details

Microservices offer many benefits:

  • They provide highly scalable solutions.
  • You can deploy each service independently.
  • Fault isolation is straightforward when you confine functionality to separate containers.
  • They fit well in a DevOps environment.
  • They decrease time to market by speeding up the software development lifecycle.

An efficient way to implement microservices is to use a serverless technology. This solution uses Functions, an Azure offering that provides a serverless compute experience. The solution uses Azure Cosmos DB for data storage. Azure Cosmos DB offers a change feed that integrates with Functions.

Potential use cases

This solution applies to many areas:

  • E-commerce
  • Retail
  • Inventory management

Next steps

See the following architectures that include Functions and Azure Cosmos DB:

See the following architectures that feature Functions:

See the following architectures that feature Azure Cosmos DB: