Category Archives: Dapr

Trying out Dapr

Note: This post was written a while back but sat in draft. I’ve published this now, but I’m not sure it’s relevant to the latest versions etc. so please bear this in mind.

I’ve been messing around with microservices in one form or another. Once you start down this route (at least in a Microsoft world) you come across Dapr (Distributed Application Runtime). Let’s take a look at what it offers us.

To get started simple visit Getting started with Dapr and follow the steps to install and initialize Dapr, I’m going to reproduce the current steps here for completeness.

  • Install Dapr, I’m doing this on a Linux box hence using
    wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash
    
  • Verify the installation by running
    dapr
    
  • Initialize dapr by running
    dapr init
    

    this will download and set up components, which basically means it’s download and then run up openzipkin/zipkin, daprio/dapr and redis docker images, so now we can check those by running

    docker ps
    
  • Dapr creates a components directory, for Linix here $HOME/.dapr and for Windows here %USERPROFILE%\.dapr\

All installed, now what?

Dapr is a sidecar architecture which basically means it exposes HTTP and gRPC either via container or process. So applications do not need to reference Dapr’s runtime instead they use Dapr as a service. The sidecar pattern is classed as a cloud design pattern.

What Dapr’s done is given us some “standard” application combination, accessible via Dapr in an agnostic manner, i.e. via HTTP calls, we can run up an instance of Dapr using

dapr run --apo-id {your-app-id} --dapr-htt-port {the-port-to-access-dapr}

So for example dapr run –app-id myapp –dapr-http-port 3500 will run Dapr up on port 3500 with the app_id of myapp.

The output from the above command will show metrics running on (in my case) port 44333. We can access this from our browser.

By default, zipkin is running on port 9411 (just check docker ps) and can be accessed from your browser using http://{your-server-ip}:9411/zipkin/

As Redis is also running we can access it using the Redis CLI, for example

docker exec -it dapr_redis redis-cli