All Projects → Azure-Samples → Saga Orchestration Serverless

Azure-Samples / Saga Orchestration Serverless

Licence: mit
An orchestration-based saga implementation reference in a serverless architecture

Projects that are alternatives of or similar to Saga Orchestration Serverless

Imgbot
An Azure Function solution to crawl through all of your image files in GitHub and losslessly compress them. This will make the file size go down, but leave the dimensions and quality untouched. Once it's done, ImgBot will open a pull request for you to review and merge. [email protected]
Stars: ✭ 732 (+438.24%)
Mutual labels:  azure, azure-functions
Azure For Developers Workshop
The Azure cloud is huge and the vast service catalog may appear daunting at first, but it doesn’t have to be!
Stars: ✭ 38 (-72.06%)
Mutual labels:  azure, azure-functions
Aks Engine
AKS Engine: Units of Kubernetes on Azure!
Stars: ✭ 833 (+512.5%)
Mutual labels:  azure, orchestration
Azure Readiness Checklist
This checklist is your guide to the best practices for deploying secure, scalable, and highly available infrastructure in Azure. Before you go live, go through each item, and make sure you haven't missed anything important!
Stars: ✭ 457 (+236.03%)
Mutual labels:  azure, azure-functions
Azure Iot Developer Kit
A curated list of awesome Azure IoT Developer Kit projects and resources.
Stars: ✭ 73 (-46.32%)
Mutual labels:  azure, azure-functions
Rockpaperscissorslizardspock
Rock, Paper, Scissors, Lizard, Spock - Sample Application
Stars: ✭ 477 (+250.74%)
Mutual labels:  azure, azure-functions
Cadscenario personalisation
This is a end to end Personalisation business scenario
Stars: ✭ 10 (-92.65%)
Mutual labels:  azure, azure-functions
Service Fabric
We've moved!
Stars: ✭ 258 (+89.71%)
Mutual labels:  azure, orchestration
Serverless Graphql Workshop
GraphQL and Serverless workshop
Stars: ✭ 70 (-48.53%)
Mutual labels:  azure, azure-functions
Developing Solutions Azure Exam
This repository contains resources for the Exam AZ-203: Developing Solutions for Microsoft Azure. You can find direct links to resources and and practice resources to test yourself ☁️🎓📚
Stars: ✭ 59 (-56.62%)
Mutual labels:  azure, azure-functions
25 Days Of Serverless
Repository responsible for 25 days of Serverless challenges
Stars: ✭ 400 (+194.12%)
Mutual labels:  azure, azure-functions
Azure Functions Rs
Create Azure Functions with Rust!
Stars: ✭ 117 (-13.97%)
Mutual labels:  azure, azure-functions
Appservice Acmebot
Automated ACME issuer for Azure App Service (Web Apps / Functions / Containers)
Stars: ✭ 281 (+106.62%)
Mutual labels:  azure, azure-functions
Letsencrypt Siteextension
Azure Web App Site Extension for easy installation and configuration of Let's Encrypt issued SSL certifcates for custom domain names.
Stars: ✭ 727 (+434.56%)
Mutual labels:  azure, azure-functions
Azure Functions Python Samples
Azure Functions Python Sample Codes
Stars: ✭ 266 (+95.59%)
Mutual labels:  azure, azure-functions
Serverlessazurefriday
Serverless geo-replicated event-based architecture sample for Azure Friday
Stars: ✭ 17 (-87.5%)
Mutual labels:  azure, azure-functions
cortana-intelligence-customer360
This repository contains instructions and code to deploy a customer 360 profile solution on Azure stack using the Cortana Intelligence Suite.
Stars: ✭ 22 (-83.82%)
Mutual labels:  azure, azure-functions
faaskit
A lightweight middleware framework for functions as a service
Stars: ✭ 24 (-82.35%)
Mutual labels:  azure, azure-functions
Acs Engine
WE HAVE MOVED: Please join us at Azure/aks-engine!
Stars: ✭ 1,049 (+671.32%)
Mutual labels:  azure, orchestration
Serverless Url Shortener
Azure Function for a URL shortening website. Uses serverless functions, Azure Table Storage and Application Insights.
Stars: ✭ 113 (-16.91%)
Mutual labels:  azure, azure-functions

page_type: sample languages:

  • csharp products:
  • azure
  • terraform
  • azure-functions
  • azure-event-hubs
  • azure-cosmosdb description: "Orchestration-based Saga implementation reference in a Serverless architecture on Azure"

Orchestration-based Saga on Serverless

saga-build

Contoso Bank is building a new payment platform leveraging the development of microservices to rapidly offer new features in the market, where legacy and new applications coexist. Operations are now distributed across applications and databases, and Contoso needs a new architecture and implementation design to ensure data consistency on financial transactions.

The traditional ACID approach is not suited anymore for Contoso Bank as the data of operations are now spanned into isolated databases. Instead of ACID transactions, a Saga addresses the challenge by coordinating a workflow through a message-driven sequence of local transactions to ensure data consistency.

About the solution

The solution simulates a money transfer scenario, where an amount is transferred between bank accounts through credit/debit operations and an operation receipt is generated for the requester. It is a Saga pattern implementation reference through an orchestration approach in a serverless architecture on Azure. The solution leverages Azure Functions for the implementation of Saga participants, Azure Durable Functions for the implementation of the Saga orchestrator, Azure Event Hubs as the data streaming platform and Azure Cosmos DB as the database service.

The implementation reference addresses the following challenges and concerns from Contoso Bank:

  • Developer experience: A solution that allows developers focus only on the business logic of the Saga participants and simplify the implementation of stateful workflows on the Saga orchestrator. The proposed solution leverages the Azure Functions programming model, reducing the overhead on state management, checkpointing (mechanism that updates the offset of a messaging partition when a consumer service processes a message) and restarts in case of failures.

  • Resiliency: A solution capable of handling a set of potential transient failures (e.g. operation retries on databases and message streaming platforms, timeout handling). The proposed solution applies a set of design patterns (e.g. Retry and Circuit Breaker) on operations with Event Hubs and Cosmos DB, as well as timeout handling on the production of commands and events.

  • Idempotency: A solution where each Saga participant can execute multiple times and provide the same result to reduce side effects, as well as to ensure data consistency. The proposed solution relies on validations on Cosmos DB for idempotency, making sure there is no duplication on the transaction state and no duplication on the creation of events.

  • Observability: A solution that is capable of monitoring and tracking the Saga workflow states per transaction. The proposed solution leverages Cosmos DB collections that allows the track of the workflow by applying a single query.

Potential use cases

These other uses cases have similar design patterns:

  • Settlement transactions
  • Order services (e.g. e-commerce, food delivery, flight/hotel/taxi booking)

Architecture

Architecture Overview

Check the following sections about the core components of the solution, workflows and design decisions:

Maturity Level

These are the top skills required for Solution Architects and Developer Leads that will reuse the proposed solution or parts of the implementation as reference:

  • Architectures: Microservices, Event-driven and Serverless
  • Design Patterns: Saga, Database-per-microservice, Async HTTP API, Retry, Circuit Breaker
  • Azure services: Azure Functions (including Event Hubs + Cosmos DB bindings and Durable Functions extension), Event Hubs, Cosmos DB, Azure Storage
  • Programming Language: C#
  • Additional concepts: Infrastructure as Code, RESTful APIs, idempotency

Repository Structure

Outline the file contents of the repository. It helps users navigate the codebase, build configuration and any related assets.

File/folder Description
docs Contains the project docs and images
src Contains the sample source code
.gitignore Defines what files to be igored at commit time
CODE_OF_CONDUCT.md Microsoft Open Source Code of Conduct
CONTRIBUTING.md Guidelines for contributing to the sample
LICENSE The license defined for the sample
README.md Project wiki
SECURITY Security guidelines for the sample

The src folder contains a set of .NET Core solutions:

Project Description
Saga.Common Solution that contains a set of reusable abstractions, models, commands and events objects and utilities
Saga.Common.Tests Solution that contains all unit tests for common utilities and processors
Saga.Functions Solution that contains all Azure Functions
Saga.Functions.Tests Solution that contains all Azure Functions unit tests
Saga.Orchestration Solution that contains domain models and the coordination logic for the Saga Orchestrator
Saga.Orchestration.Tests Solution that contains unit tests for the Saga Orchestrator
Saga.Participants Solution that contains domain models and business logic of all Saga participants
Saga.Participants.Tests Solution that contains unit tests of all Saga participants

Prerequisites

If Visual Studio Code is your platform preference for development:

If Visual Studio is your platform preference for development:

Getting Started

1. Create the infrastructure

Follow the instructions on Create Infrastructure as Code to create a new GitHub Actions pipeline that creates the required infrastructure on Azure through Terraform.

2. Creating the application settings

The solution requires a set of environment variables to be configured on Saga.Functions solution for running the project locally. Follow the Configuring the Azure Functions Application Settings instructions to create a local.settings.json. Make sure the settings are configured before proceeding to the next step.

4. Running unit tests

Run the following command on test projects:

dotnet test

5. Running the solution

For running the solution through command line, make sure you're on the src/Saga.Functions directory then run the following command:

func host start

The solution provides a Swagger UI on http://localhost:<port>/api/swagger/ui.

Swagger UI

You can start a new HTTP request on /api/saga/start route by providing the following json as part of the body content:

{
    "accountFromId": "<random ID>",
    "accountToId": "<random ID>",
    "amount": 100.00
}

After executing the request, it's expected to receive the transaction ID as part of the HTTP response.

Saga Starter request

You can check the documents created on Cosmos DB. It is expected to have the following document structure on the orchestrator collection:

{
  "accountFromId": "<random bank account ID>",
  "accountToId": "<random bank account ID>",
  "amount": 100,
  "id": "<random transaction ID>",
  "type": "Default",
  "state": "Success",
  ...
}

For observability, check the saga collection that contains all events processed by the orchestrator. It is expected to have the following structure:

{
  "transactionId": "<random transaction ID>",
  "source": "<Validator, Transfer or Receipt>",
  "messageType": "<event name>",
  "creationDate": "<event creation date>",
  ...
}

Next Steps

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].