coffeeshop-on-dapr
coffeeshop-on-dapr copied to clipboard
The coffeeshop event-driven application is developed in C# and runs on Dapr (AKS)
coffeeshop-on-dapr
The .NET coffeeshop application runs on Dapr
Services
| No. | Service Name | URI |
| 1 | product-service | http://localhost:5001 |
| 2 | counter-service | http://localhost:5002 |
| 3 | barista-service | http://localhost:5003 |
| 4 | kitchen-service | http://localhost:5004 |
| 5 | reverse-proxy | http://localhost:8080 |
Featured technologies
- .NET 7 - .NET is a free, cross-platform, open-source developer platform for building many different types of applications.
- Bicep - Infrastructure as code
- Bicep extensibility Kubernetes provider - Model Kubernetes resources in Bicep
- Azure Kubernetes Service
- Azure Service Bus
- Dapr - Microservice building blocks
- KEDA - Kubernetes event-driven autoscaling
Architecture

Pre-requisites
- Azure subscription
- Note: This application will create Azure resources that will incur costs.
- Azure CLI
- Dapr CLI
- Helm
- Docker
- Dotnet SDK
- Bicep extensibility
- vscode extensions:
- ms-vscode.azure-account
- ms-azuretools.vscode-bicep
- ms-kubernetes-tools.vscode-kubernetes-tools
- humao.rest-client
Get starting locally
> dapr init
> docker compose up
Finally, you can play around using client.http to explore the application!
Make sure no
redis,zipkininstances running
Get starting on Azure
-
Ensure you have access to an Azure subscription and the Azure CLI installed
az login az account set --subscription "My Subscription" -
Clone this repository
git clone https://github.com/thangchung/coffeeshop-on-dapr.git cd coffeeshop-on-dapr -
Install KEDA extension
Enable KEDA extension here
az feature register --namespace "Microsoft.ContainerService" --name "AKS-KedaPreview" -
Deploy the infrastructure
az deployment sub create --location eastus --template-file ./iac/bicep/main.bicep -
Install Dapr extension
Enable Dapr extension here
az k8s-extension create --cluster-type managedClusters --cluster-name coffeeshop --resource-group azure_oss_rg --name dapr --extension-type Microsoft.Dapr -
Log into Azure Container Registry You can get your registry name from your resource group in the Azure Portal
# enable admin login on Azure Portal docker login <registry_server_uri> -u <admin username> -p <password>For example: <registry_server_uri> looks like
coffeeshopf2syic6ephtxk.azurecr.io -
Build and push containers
Create an .env file at root project folder with content
DOCKER_REGISTRY=<registry_server_uri>Then run docker-compose CLI as
docker compose build docker push <registry_server_uri>/product-service:latest docker push <registry_server_uri>/counter-service:latest docker push <registry_server_uri>/barista-service:latest docker push <registry_server_uri>/kitchen-service:latest docker push <registry_server_uri>/reverse-proxy:latest -
Get AKS credentials
az aks get-credentials --resource-group az_oss_rg --name coffeeshopMake sure when you go to Azure Portal, you should see
kedaanddaprcomponents as the picture below
-
Create dapr component on AKS
kubectl apply -f iac/dapr/azure/orderup_pubsub.yaml kubectl apply -f iac/dapr/azure/barista_pubsub.yaml kubectl apply -f iac/dapr/azure/kitchen_pubsub.yaml -
Deploy the application
az deployment group create --resource-group az_oss_rg --template-file ./iac/bicep/app.bicep -
Get your frontend URL
kubectl get ingressFor example,
NAME CLASS HOSTS ADDRESS PORTS AGE reverseproxy app.5cde744b1d1242ffbc32.eastus.aksapp.io 20.241.232.155 80 13m -
Navigate to client.http, and change
@hostto what you can see on previous command, for example:app.5cde744b1d1242ffbc32.eastus.aksapp.io, then play with REST APIs there. Enjoy!
Clean up
az group delete -n az_oss_rg
Credits
- https://github.com/Azure-Samples/PetSpotR