Skip to content

petabridge/azure-app-service-akkadotnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Akka.NET: Shopping Cart App

A canonical shopping cart sample application, built using Akka.NET. This app shows the following features:

  • Shopping cart: A simple shopping cart application that uses Akka.NET 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.

Shopping Cart sample app running.

Features

The app is architected as follows:

Shopping Cart sample app architecture.

Get Started

Prerequisites

Quickstart

  1. git clone git@github.com:petabridge/azure-app-service-akkadotnet.git akka-on-app-service
  2. cd akka-on-app-service
  3. dotnet run --project src\Akka.ShoppingCart\Akka.ShoppingCart.csproj

Deploying To Azure App Services

Create a Resource Group

Before deploying the app, you need to create an Azure Resource Group (or you could choose to use an existing one). To create a new Azure Resource Group, use one of the following articles:

Prepare For Azure Deployment

The app will need to be packaged for deployment. In the Akka.ShoppingCart project we define a Target element that runs after the Publish step. This will zip the publish directory into a cluster.zip file:

<Target Name="ZipPublishOutput" AfterTargets="Publish">
    <Delete Files="$(ProjectDir)\..\..\cluster.zip" />
    <ZipDirectory SourceDirectory="$(PublishDir)" DestinationFile="$(ProjectDir)\..\..\cluster.zip" />
</Target>

In this tutorial, we will be using Azure CLI and Azure Bicep to create all of the resources needed by the example project and to deploy the packaged cluster.zip file into Azure App Services.

Provision Required Azure Resources

We will use PowerShell, Azure CLI, and the provided .bicep files to automate our Azure resource creation. In PowerShell, navigate to the project directory and deploy the resources using az deployment group create.

Replace <resource-group-name> with the name of the Azure Resource Group you created earlier and replace <unique-application-name> with a unique name to identify your web application.

az deployment group create `
  --resource-group <resource-group-name> `
  --template-file 'flex/main.bicep' `
  --parameters appName=<unique-application-name> `
  --debug

Publishing And Deploying The Sample Project

Publish the Akka.ShoppingCart project by using the dotnet publish command in PowerShell

dotnet publish --configuration Release .\src\Akka.ShoppingCart\Akka.ShoppingCart.csproj 

Deploy the published cluster.zip file to Azure App Services using az webapp deploy. Again, replace <resource-group-name> and <unique-application-name> the same names you used in the earlier step.

az webapp deploy --name <unique-application-name> `
  --resource-group <resource-group-name> `
  --clean true --restart true `
  --type zip --src-path cluster.zip --debug

Azure App Service will take a few minutes to spin up the web application that will contain a single node Akka.NET cluster. To view the deployed web application, you can go to https://<unique-application-name>.azurewebsites.net.

See Akka.Discovery.Azure In Action

You can see Akka.Discovery.Azure in action by scaling out and increasing the minimum number of server instances in your Azure App Service Plan via Azure Portal.

  • In the Azure portal, select your web app name (App service), and in the left menu pane, under Settings, select Scale out (App Service plan). The Scale out (App Service plan) pane appears.
  • On the Configure tab, select Manual scale and set the Instance count to 5. In the top menu bar, select Save.

Scale out the deployment to 5 instances.

Use the Cluster Status link on the left navigation bar of the deployed website to monitor the cluster state changes as new nodes joins the cluster in real time.

Explore The Bicep Templates

The Bicep files used in this example is nearly identical to the one used in the Orleans example. As noted in their documentation, one very important resource is that of the Virtual Network. The vnet resource enables the Azure App Service to communicate with the Akka.NET cluster.

To read more about the Bicep files and how they are used in resource provisioning, please read the documentation.

Acknowledgements

The Akka.ShoppingCart project uses the following 3rd party open-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:

About

Demo for Akka.NET on Azure App Service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published