Tag Archives: dapr

Speaking at NT conference 2021 – Dapr

After a year of presenting/delivering sessions/workshop online, I had the opportunity to talk in front of people in person. The talk was about Dapr at NT conference in Portorož, Slovenia, and how it can be used in Azure environment with services like Service Bus, Azure KeyVault, Azure Table Storage and Azure Kubernetes Service.

Source code walkthrough

Source code is available here, YAML files for AKS here. Slides can be downloaded here.

Demo structure

You will find 3 zip files inside, each with demos for the parts of the talk:

  • HelloDapr – contains demo example on how to start with Dapr and use it in your app
  • Building Blocks – which contains calls to service bus, event hub, local (cloud based) secret solutions and web project handling messages from Service Bus / Event Hub in real-time with Azure SignalR
  • State Management – contains code, which uses table storage to store data in CLI and an example with web application, which calls web api via REST and web api contains code for storing state via Dapr – this web solution is also deployed in Azure Kubernetes Service as frontend, which is exposed via public IP to the world and REST API with private address, being access by frontend.

I also used a distributed calculator example from official Dapr quickstart on Github as an example of how service invoke component works.

Prerequisites for demos to work

  • In order to start with demos, you will need to have Dapr installed. Even though you can install Dapr without dependency on docker (more here), I do recommend having docker installed and work with that. Instruction, how to get started, here.
  • As majority of the demos are in .NET you will need to have .NET installed. Follow this tutorial to install and configure your environment to run the demos.
  • if you would like to test out Azure EventHub, Azure Service Bus, Azure Signalr, Azure Table Storage, Azure KeyVault, Azure Kubernetes Service, you will need a subscription. You can create trial account or use other available option (you can use your Visual Studio Subscription with available credits, if you have some).
  • If you want to run demos in AKS, you will need to configure AKS to run Dapr. Follow this tutorial here (kubectl is recommended to be installed as well).

Demo 1: Hello World

The first demo is about how to get started with Dapr, manually via Dapr CLI or programmatically. After Dapr install open terminal window and execute following commands to expore Dapr before going into code.

dapr run --app-id myapp --dapr-http-port 3500

dapr dashboard > go to http://localhost:8080

curl -UseBasicParsing http://localhost:3500/v1.0/metadata
curl -UseBasicParsing http://localhost:3500/v1.0/healthz

--call below  to save data
Invoke-RestMethod -Method Post -ContentType 'application/json' -Body '[{ "key": "name", "value": "Hello Dapr"}]' -Uri 'http://localhost:3500/v1.0/state/statestore’

--call to get data
Invoke-RestMethod -Uri 'http://localhost:3500/v1.0/state/statestore/name’

--go to dapr folder and showcase data
cd .dapr
docker container ls
docker exec -it dapr_redis redis-cli

--inside do a call to keys
hgetall "myapp||name“


After initial lap around manual calls, you can open solution file in folder HelloDaprSLN in your favorite editor (if you don’t have editor installed, you can use .NET Cli to start the solution – more here) and run the code. Before you run the code. check Program.cs for instructions in comments (you need to run sidecar to communicate with them via HTTP).

dapr run --app-id hello-dapr --dapr-http-port 3600
dapr run --app-id hello-dapr-custom --dapr-http-port 3700 --components-path .\dev-components

Demo 2: Building blocks

In demo 2 we are exploring pub-sub and secret components. Open the solution in editor of your choice (or CLI) and first run the code in Building-Blocks-Secret-Cli.

Before you run the code, you need to initiate Dapr sidecar:

dapr run --app-id my-secrets-app --dapr-http-port 3500 --components-path ./Components/

If you would like to run Azure KeyVault demo, you need to configure azurekeyvault.yaml in folder Components. How to do that, follow this tutorial and populate values and run the code again.

After first demo open Building-Blocks-Cli demo and populate values in Components folder. In order to have this working, you will need to have Azure Service Bus. Follow this tutorial to enable Azure Service Bus access and populate values in servicebus.yaml file.

Before you run the code you will need to initiate the Dapr sidecar:

dapr run --app-id dapr-sb --app-port 5002 --components path ./Components --dapr-grpc-port 50001

Run the code. After your code is successfully launched, open Building-Blocks-Web. You will need to specify 2 environment variables, ASPNETCORE_URLS=http://localhost:5002 and Azure:SignalR:ConnectionString=SIGNALR-CONN-STRING (check this demo) in order to lunch the app. When launched (open http://localhost:5002 in your browser), you will automatically connect to SignalR and listen for incoming requests. Run the Building-Blocks-Cli again to send messages and check them in real-time on the web.

Demo 3: State management

Demo 3 focused on state management, namely working with different providers – in this case local redis state or Azure Table Storage. Open State-Management-Dapr-Cli project first and populate values in Components folder. In order to setup Azure Table Storage follow this tutorial.

Run Dapr sidecar before running the code:

dapr run --app-id state-management-app --dapr-grpc-port 50001 --components-path ./Components/

In order to run the web solution, you will need to run Dapr sidecar with following command:

dapr run --app-id state-management-web-api --dapr-grpc-port 50001 --app-port 5002

After that you need to run the State-Management-Dapr-Web-Api solution first with environment variable ASPNETCORE_URLS=http://localhost:5002.

In order to see the value, run the solution State-Managent-Web and navigate to provided URL.

Demo 3: Run in Azure Kubernetes Service

If you want to run the solution State-Management-Dapr-Web-Api and State-Managent-Web in Azure Kubernetes Service, you need to build container images and deploy them to registry of your choice. I do recommend Azure Container Registry as it has also an ability to build container images directly via az cli (follow this tutorial for more).

Folder contains also 2 docker files, Dockerfileweb and DockerfileWebApi, which will be used for deployment purposes.

After you have built the image, you can deploy them to Kubernetes. To do that, change values in this YAML files (web.yaml and web-api.yaml).

Yaml for web and API

To see the result, issue command to get public IP, navigating to the namespace you created (kubectl get svc -n yournamespace). Copy the IP, open it in brower and test out the demo.


Speaking in front of people in the pandemic is a different experience. It feels weird in the beginning, but it feels right and normal after a few minutes. I really looked forward to this experience and am thankful to have the opportunity to share demos about great framework for building distributed applications – Dapr.