This repository contains a simple C# demo app that demonstrates the power of Dapr for microservices (Blog Post). The app consists of two ASP.NET Core Web API services and a C# Console App. The first service generates a random number, and the second one squares it. We use Dapr for service invocation and state management.
- NumberGenerator: An ASP.NET Core Web API service that generates a random number.
- SquaringService: An ASP.NET Core Web API service that squares a given number.
- DaprExampleApp: A C# Console App that invokes the two services and saves the generated number and its square using Dapr's state management
- Clone the repository:
git clone https://github.com/Westmorland/NumberGenerator.git
cd NumberGenerator
- Run the Number Generator service with Dapr:
Open a terminal, navigate to the
NumberGenerator
folder, and run the following command:
dapr run --app-id numbergenerator --app-port 7000 --dapr-http-port 3500 dotnet run
- Run the Squaring Service with Dapr: Open a new terminal, navigate to the SquaringService folder, and run the following command:
dapr run --app-id squaringservice --app-port 7001 dotnet run
- Run the Console App: Open a third terminal, navigate to the DaprExampleApp folder, and run the following command:
dotnet run
- Check the output: You should see the generated number and its square printed to the console.
The Console App performs the following steps:
- It generates a random number by invoking the
NumberGenerator
service using Dapr's service invocation API. - It squares the generated number by invoking the
SquaringService
using Dapr's service invocation API. - It saves the generated number and its square using Dapr's state management API.
Feel free to explore the code, modify the services, or add new features!
We welcome contributions! If you find a bug, have a suggestion, or want to improve the code, please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.