Orleans: Shopping Cart App sample
A canonical shopping cart sample application, built using Microsoft Orleans. This app shows the following features:
Shopping cart: A simple shopping cart application that uses Orleans for its cross-platform framework support, and its scalable distributed applications capabilities.
- Inventory management: Edit and/or create product inventory.
- Shop inventory: Explore purchasable products and add them to your cart.
- Cart: View a summary of all the items in your cart, and manage these items; either removing or changing the quantity of each item.
Features
- .NET 8
- ASP.NET Core Blazor
- Orleans: Grain persistence
- Azure Storage grain persistence
- Orleans: Code generation
- Orleans: Startup tasks
- Azure Bicep
- Azure App Service
- GitHub Actions and .NET
The app is architected as follows:
Get Started
Prerequisites
- A GitHub account
- The .NET 8 SDK or later
- The Azure CLI
- A .NET integrated development environment (IDE)
- Feel free to use the Visual Studio IDE or the Visual Studio Code
Quickstart
git clone https://github.com/Azure-Samples/Orleans-Cluster-on-Azure-App-Service.git orleans-on-app-service
cd orleans-on-app-service
dotnet run --project Silo\Orleans.ShoppingCart.Silo.csproj
Deploying to Azure
Before deploying to Azure, make sure you complete the following steps:
- Create an Azure Cosmos DB for NoSQL account.
- Create a database named
Orleans
. - Within the
Orleans
database, create a container namedOrleansStorage
with a partition key path of/PartitionKey
. - Create another container named
OrleansCluster
within theOrleans
database. Ensure this container has a partition key path of/ClusterId
. - Get the connection string.
- Create a database named
- Create an Azure Container App as the target of your deployment.
- Ensure that the target ingress port is
8080
. For more information, see default ASP.NET Core port changed to 8080. - Create a secret in the Container App for the Azure Cosmos DB for NoSQL account's connection string.
- Create an environment variable in the Container App's container named
ORLEANS_AZURE_COSMOS_DB_CONNECTION_STRING
. Reference the secret you just created.
- Ensure that the target ingress port is
- Deploy the application to the Azure Container App service. For more information, see Azure Container Apps deployment options.
Build docker image locally
- Install Docker Desktop from Docker Hub
- Run
docker build -t orleans-shopping-cart -f Silo/Dockerfile .
to build the docker image locally
Acknowledgements
The Orleans.ShoppingCart.Silo project uses the following open3rd party-source projects:
- MudBlazor: Blazor Component Library based on Material design.
- Bogus: A simple fake data generator for C#, F#, and VB.NET.
- Blazorators: Source-generated packages for Blazor JavaScript interop.
Derived from IEvangelist/orleans-shopping-cart.