The .NET coffeeshop application runs on Dapr
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 |
- .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
- 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
> dapr init
> docker compose up
Finally, you can play around using client.http to explore the application!
Make sure no
redis
,zipkin
instances running
-
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 coffeeshop
Make sure when you go to Azure Portal, you should see
keda
anddapr
components 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 ingress
For 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
@host
to what you can see on previous command, for example:app.5cde744b1d1242ffbc32.eastus.aksapp.io
, then play with REST APIs there. Enjoy!
az group delete -n az_oss_rg