{"id":26642828,"url":"https://github.com/whiteducksoftware/dapr-demo","last_synced_at":"2025-03-24T19:28:11.610Z","repository":{"id":40400885,"uuid":"338089585","full_name":"whiteducksoftware/dapr-demo","owner":"whiteducksoftware","description":"This repository contains a simple demo to show how Dapr can help to implement a polyglot microservice-based architecture.","archived":false,"fork":false,"pushed_at":"2022-05-20T10:11:02.000Z","size":549,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2023-03-06T15:41:17.003Z","etag":null,"topics":["cloudnative","dapr","demo","kubernetes","microservice"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whiteducksoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-11T16:47:48.000Z","updated_at":"2023-02-18T13:29:20.000Z","dependencies_parsed_at":"2022-08-09T19:20:58.575Z","dependency_job_id":null,"html_url":"https://github.com/whiteducksoftware/dapr-demo","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whiteducksoftware%2Fdapr-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whiteducksoftware%2Fdapr-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whiteducksoftware%2Fdapr-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whiteducksoftware%2Fdapr-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whiteducksoftware","download_url":"https://codeload.github.com/whiteducksoftware/dapr-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245337197,"owners_count":20598834,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudnative","dapr","demo","kubernetes","microservice"],"created_at":"2025-03-24T19:28:10.792Z","updated_at":"2025-03-24T19:28:11.600Z","avatar_url":"https://github.com/whiteducksoftware.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dapr demo\n\nThis repository contains a simple demo that shows how [Dapr](https://dapr.io/) _simplifies the implementation of polyglot microservices_ and how Dapr makes it possible _to switch between different deployment environments_ without changing the application code.\n\nThe demo consists of three applications.\n\n- **Client**: Written in _Go_, uses dapr **service invocation** to talk to the MessageService over _GRPC_.\n- **MessageService**: Written in _C# .NET 6_, uses dapr **state management** to persist state and also uses the **publish \u0026 subscribe** building block to publish messages.\n- **NotificationService**: Written in _TypeScript / Node.js_, uses the **publish \u0026 subscribe** building block to subscribe on messages from the MessageService and outputs them on the console.\n\n![architecture](./assets/architecture.png)\n\n## Changing the deployment environment with Dapr\n\nThe demo shows how Dapr enables polyglot microservices to run in different environments (e.g. local and cloud) without changing a line of application code.\nFor this purpose, the demo uses different third-party components for each environment.\n\nThird-party components used in local environments:\n\n- Redis (State store and message broker)\n- Zipkin (Distributed Tracing)\n\nThird-party components used in cloud environments:\n\n- Azure CosmosDB (State store)\n- Azure Service Bus (Message broker)\n- Azure Application Insights with OpenTelemetry collector (Distributed Tracing)\n\n## Run the demo in Kubernetes\n\nThe Dapr components definitions for running the demo on Kubernetes are located in the `/dapr/kubernetes/` directory.\n\n### Run on AKS using Azure services\n\nFollow these steps to run the Dapr demo on Azure Kubernetes Service (AKS) using Azure services as third-party components.\n\n#### Prerequisites for Kubernetes deployment on Azure Cloud\n\nTo run the Dapr demo on Kubernetes in Azure, you need running instances of the following services.\n\n- Azure Kubernetes Service with installed Dapr ([Deploy Dapr on a Kubernetes cluster](https://docs.dapr.io/operations/hosting/kubernetes/kubernetes-deploy/))\n- Azure CosmosDB ([Dapr Docs for Azure CosmosDB setup](https://docs.dapr.io/reference/components-reference/supported-state-stores/setup-azure-cosmosdb/))\n- Azure Service Bus ([Dapr Docs for Azure Service Bus setup](https://docs.dapr.io/reference/components-reference/supported-pubsub/setup-azure-servicebus/))\n- Azure Application Insights ([Dapr Docs on using Application Insights with OpenTelemetry Collector](https://docs.dapr.io/operations/monitoring/tracing/open-telemetry-collector-appinsights/))\n- kubectl\n\nAdditionally, you will need to create kubernetes secrets to connect to the Azure services.\nSet the required parameters as value.\nRefer to the Dapr Docs for details on connection parameters.\n\n- Create a kubernetes secret named `cosmos-db-secrets` with the following keys:\n  - url\n  - masterKey\n  - database\n  - collection\n- Create a kubernetes secret named `servicebus-secrets` with the following key:\n  - connectionString\n- Configure the `instrumentation_key` in the `dapr-demo-application-insights.yaml` file by replacing `\u003cREPLACE-WITH-INSTRUMENTATION-KEY\u003e` with your Azure Application Insights instrumentation key. **Be careful to not accidentally commit your instrumentation key!**\n\n#### Deployment on AKS\n\nConnect to your AKS cluster and switch kubectl context to your AKS cluster.\nThen run the following command.\n\n```bash\nkubectl apply -f ./dapr/kubernetes/cloud\n```\n\n### Run on local Kubernetes cluster using local components\n\nFollow these steps to run the Dapr demo on a local Kubernetes cluster using local third-party components.\n\n#### Prerequisites for local Kubernetes deployment\n\n- Kubernetes with installed Dapr ([Deploy Dapr on a Kubernetes cluster](https://docs.dapr.io/operations/hosting/kubernetes/kubernetes-deploy/))\n- Redis ([Dapr Docs instructions for installing Redis in Kubernetes](https://docs.dapr.io/getting-started/configure-state-pubsub/#create-a-redis-store))\n- kubectl\n\n#### Deployment on local Kubernetes cluster\n\n```bash\nkubectl apply -f ./dapr/kubernetes/local\n```\n\n## Run the demo in self-hosted mode\n\nThe Dapr components definitions for running the demo in self-hosted mode are located in the `/dapr/self-hosted/` directory.\n\n### Prerequisites for self-hosted deployment using cloud components\n\nTo run the Dapr demo in self-hosted mode using cloud components, you will need the following prerequisites:\n\n- [.NET 6.0](https://dotnet.microsoft.com/download/dotnet/6.0)\n- [Go](https://golang.org/)\n- [Node.js with NPM](https://nodejs.org/en/)\n- [Dapr](https://dapr.io/)\n- Azure CosmosDB ([Dapr Docs for Azure CosmosDB setup](https://docs.dapr.io/reference/components-reference/supported-state-stores/setup-azure-cosmosdb/))\n- Azure Service Bus ([Dapr Docs for Azure Service Bus setup](https://docs.dapr.io/reference/components-reference/supported-pubsub/setup-azure-servicebus/))\n\nRename the provided `dapr-demo-secrets-store.json.example` file to `dapr-demo-secrets-store.json` and fill in the parameters required to connect to the components.\n\nAdditionally, you will have to **install the necessary npm packages** of the notificationservice:\n\n```powershell\ncd ./services/notificationservice\nnpm install\n```\n\n### Run in self-hosted mode using cloud components\n\nStart the services in the following order and wait until you see `You're up and running! Both Dapr and your app logs will appear here.` as an output before starting the next service.\n\n#### Start the Notification Service using cloud components\n\nIf you are on Windows or if you have PowerShell Core installed, you can use the `run-notification-service.ps1` to start the application:\n\n```powershell\ncd ./dapr/self-hosted/cloud\n./run-notification-service.ps1\n```\n\nOtherwise, start the application using the dapr CLI:\n\n```bash\ncd ./services/notificationservice\ndapr run `\n  --app-id dapr-demo-notification-service `\n  --app-port 5005 `\n  --components-path ../../dapr/self-hosted/cloud `\n  npm run start\n```\n\n#### Start the Message Service using cloud components\n\nIf you are on Windows or if you have PowerShell Core installed, you can use the `run-message-service.ps1` to start the application:\n\n```powershell\ncd ./dapr/self-hosted/cloud\n./run-message-service.ps1\n```\n\nOtherwise, start the application using the dapr cli:\n\n```bash\ncd ./services/messageservice\ndapr run `\n    --app-id dapr-demo-message-service `\n    --app-port 5002 `\n    --app-protocol grpc `\n    --components-path ../../dapr/self-hosted/cloud `\n    dotnet run\n```\n\n#### Start the Client using cloud components\n\nIf you are on Windows or if you have PowerShell Core installed, you can use the `run-client.ps1` to start the application:\n\n```powershell\ncd ./dapr/self-hosted/cloud\n./run-client.ps1\n```\n\nOtherwise, start the application using the dapr CLI:\n\n```bash\ncd ./services/client\ndapr run `\n    --app-id dapr-demo-client `\n    --components-path ../../dapr/self-hosted/cloud `\n    go run main.go\n```\n\n### Prerequisites for self-hosted deployment using local components\n\nTo run the Dapr demo in self-hosted mode using local components, you need the following prerequisites:\n\n- [.NET 6.0](https://dotnet.microsoft.com/download/dotnet/6.0)\n- [Go](https://golang.org/)\n- [Node.js with NPM](https://nodejs.org/en/)\n- [Dapr](https://dapr.io/)\n- Redis (Automatically installed with Dapr)\n\nRename the provided `dapr-demo-secrets-store.json.example` file to `dapr-demo-secrets-store.json` and fill in the parameters required to connect to the components.\n\nAdditionally, you will have to **install the necessary npm packages** of the notificationservice:\n\n```powershell\ncd ./services/notificationservice\nnpm install\n```\n\n### Run in self-hosted mode using local components\n\nStart the services in the following order and wait until you see `You're up and running! Both Dapr and your app logs will appear here.` as an output before starting the next service.\n\n#### Start the Notification Service using local components\n\nIf you are on Windows or if you have PowerShell Core installed, you can use the `run-notification-service.ps1` to start the application:\n\n```powershell\ncd ./dapr/self-hosted/local\n./run-notification-service.ps1\n```\n\nOtherwise, start the application using the dapr cli:\n\n```bash\ncd ./services/notificationservice\ndapr run `\n  --app-id dapr-demo-notification-service `\n  --app-port 5005 `\n  --components-path ../../dapr/self-hosted/local `\n  npm run start\n```\n\n#### Start the Message Service using local components\n\nIf you are on Windows or if you have PowerShell Core installed, you can use the `run-message-service.ps1` to start the application:\n\n```powershell\ncd ./dapr/self-hosted/local\n./run-message-service.ps1\n```\n\nOtherwise, start the application using the dapr CLI:\n\n```bash\ncd ./services/messageservice\ndapr run `\n    --app-id dapr-demo-message-service `\n    --app-port 5002 `\n    --app-protocol grpc `\n    --components-path ../../dapr/self-hosted/local `\n    dotnet run\n```\n\n#### Start the Client using local components\n\nIf you are on Windows or if you have PowerShell Core installed, you can use the `run-client.ps1` to start the application:\n\n```powershell\ncd ./dapr/self-hosted/local\n./run-client.ps1\n```\n\nOtherwise, start the application using the dapr CLI:\n\n```bash\ncd ./services/client\ndapr run `\n    --app-id dapr-demo-client `\n    --components-path ../../dapr/self-hosted/local `\n    go run main.go\n```\n\n## Output\n\nIf everything was setup up correctly, you should see the following output of the Notification Service with an increasing counter. The output is the same for all deployment variants.\n\n![notification-service-output](./assets/notification-service-output.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhiteducksoftware%2Fdapr-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhiteducksoftware%2Fdapr-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhiteducksoftware%2Fdapr-demo/lists"}