This repository contains Service Fabric applications that utilises a variety of different service types, state and API to demonstrate various features of the Service Fabric platform and an example microservice architecture.
- Database
- Products API
- Basket API and Actor
- Orders API
- Web Application
The database is a MongoDB Guest Executable service that acts as a simple data repository. This is great for local development but ideally a PaaS service (e.g. hosted MongoDB or CosmosDB) would be used instead with proper disaster recovery enabled.
A simple Stateless Service that performs CRUD operations against the database. The connection details are saved in the Config settings deployed with the service so can be updated independently during a delta deployment.
The API is another Stateless Service that hands off the request to a Reliable Actor for the specified Basket ID. This pattern allows state to be held in a lightweight service designed for massive scale but with a limited lifetime. The actor itself can be extended to allow baskets to timeout, or to persist data in a permanent store on deactivation and to reload on activation.
This API is a Stateful Service where the API accepts orders and queues these in a Reliable Queue collection. A worker thread then dequeues these orders and updates the database. Again, the Config settings are utilised by this service for delta upgrades.
The web application is a Stateless Service that serves an ASP.NET MVC application. This application provides controllers mapped to each application making up the overall solution, and these controllers call the relevant API.
The application is deployed as a number of Service Fabric Packages. The applications have been aligned to various bound contexts within the overall solution (e.g. Products, Basket, Orders) and reduces the impact of upgrading any individual part.
In order to implement the solution, there are a number of Lab Sessions detailed below. Each of these will start from a reference branch in this repository. Details are shown below:
- Lab 1: Creating the Database
- Lab 2: Creating the Products API
- Lab 3: Creating the Web Application
- Lab 4: Creating the Basket API
- Lab 5: Creating the Orders API
- Lab 6: Creating managed cluster in Azure
- Lab 7: Setting up Azure DevOps pipelines
To build and deploy this application you will need a few tools. Here is a list of software that can be used: