Covers Dapr as a portable runtime: the daprd sidecar and its HTTP/gRPC API, the main building blocks, components that swap the backing service by YAML, the .NET SDK (Dapr.Client, Dapr.AspNetCore, Dapr.Workflow), Dapr on Azure Container Apps and AKS, and when to choose it over plain Azure SDKs.
Dapr (Distributed Application Runtime) is a CNCF graduated project that runs a sidecar (daprd) next to each service. Your app calls the sidecar over local HTTP or gRPC, and the sidecar provides building blocks: service invocation, state, pub/sub, input/output bindings, secrets, actors and workflow. Which backing service is used, say Redis or Azure Service Bus for pub/sub, is chosen by a component YAML file, not by your code.
DaprClient, plus AddDapr() and [Topic] subscriptions in ASP.NET Core.It helps polyglot or multi-cloud teams and teams that want actors or workflow without building them. The trade-off: an extra network hop, simpler but narrower APIs than the native SDKs, and one more runtime to operate.
"Dapr is a runtime that sits next to my service as a sidecar process,
daprd, and gives me distributed-systems capabilities through a local API. Instead of my code taking a dependency on the Service Bus SDK, it posts tolocalhost:3500/v1.0/publish/pubsub/orders, and a component file says thatpubsubis Azure Service Bus in production and Redis on my laptop. The same pattern covers service invocation, state stores, bindings to things like queues and cron, secrets, the actor model and durable workflows.In .NET the SDK makes it feel native:
DaprClientfor publishing, state and invocation,AddDapr()andMapSubscribeHandler()so ASP.NET Core endpoints marked with[Topic("pubsub", "orders")]receive events, andDapr.Workflow, which became stable in the 1.16 release, for long-running orchestrations. On Azure Container Apps I just enable Dapr on the app and declare components on the environment; on AKS there is a managed Dapr extension. Service invocation between sidecars is mTLS-encrypted and propagates trace context automatically, and resiliency policies give me retries, timeouts and circuit breakers in YAML.The mistake I see is adopting Dapr because it sounds cloud-native, when the team is all .NET on Azure and never going to swap Service Bus for Kafka. Then you pay for an extra hop, lose features the native SDK has, like sessions or scheduled messages in some cases, and you have one more runtime to upgrade. I reach for Dapr when portability, polyglot services or actors and workflow are real requirements, not as a default."
| Building block | What it gives you | Typical backing components |
|---|---|---|
| Service invocation | Name-based calls, mTLS, retries, tracing | Sidecar to sidecar (gRPC) |
| Pub/sub | Publish and subscribe with CloudEvents envelopes, at-least-once | Azure Service Bus, Kafka, RabbitMQ, Redis Streams |
| State management | Key/value with ETags (optimistic concurrency), transactions | Redis, Cosmos DB, SQL Server, PostgreSQL |
| Bindings | Trigger on or write to external systems | Storage queues, cron, SMTP, Event Hubs |
| Secrets | Read secrets through one API | Key Vault, Kubernetes secrets |
| Actors | Virtual actors with turn-based concurrency and timers | A state store that supports actors |
| Workflow | Durable, replayed orchestrations in code | Uses the actor/state infrastructure |
| Fits | Does not fit |
|---|---|
| Polyglot services (.NET, Go, Python) that need the same messaging and state semantics | A small all-.NET team on one cloud |
| Real multi-cloud or on-premises plus cloud requirement | You need advanced broker features the abstraction hides |
| You want actors or durable workflow without Orleans or Durable Functions | Latency-critical hot paths where 1-2 ms per hop matters |
| Already on Azure Container Apps where Dapr is a toggle | No one on the team wants to own another runtime's upgrades |
A team running [six] services on Azure Container Apps used Dapr pub/sub over Service Bus and state over Redis. Local development used the same components pointed at Redis, so new starters ran the whole system with dapr run and no cloud access. The sidecar added roughly [1-2 ms] per call at p50, which was acceptable against a 200 ms API budget.
Checks whether the candidate understands what Dapr actually does mechanically and can judge when its abstraction is worth the cost.
Green flags
Red flags
+-------------------- pod / container app --------------------+
| |
| orders-api (.NET) --HTTP/gRPC localhost--> daprd sidecar |----> Service Bus (pubsub component)
| ^ | | |----> Redis (statestore component)
| | subscription callback (POST /orders) | | |
| +---------------------------------------+ +--mTLS--> other daprd --> pricing-api
+-------------------------------------------------------------+
The app never holds broker credentials: the sidecar reads the component definition (with secrets from a secret store or managed identity) and talks to the backend. The app talks to the sidecar on ports 3500 (HTTP) and 50001 (gRPC). In Kubernetes the Dapr sidecar injector adds the container to pods annotated dapr.io/enabled: "true"; the control plane (operator, placement, sentry for certificates, scheduler) runs in dapr-system.
A component is a CRD (or a YAML file in self-hosted mode):
kind: Component
metadata: { name: pubsub }
spec:
type: pubsub.azure.servicebus.topics
metadata: [ { name: namespaceName, value: sb-prod.servicebus.windows.net } ]
Swapping to pubsub.redis changes behaviour without a code change, but semantics differ: ordering, maximum message size, dead-lettering and delivery guarantees are the broker's, not Dapr's. Portability is of the API, not of guarantees.
Dapr wraps payloads in CloudEvents 1.0. On start-up the sidecar calls GET /dapr/subscribe on your app (generated by MapSubscribeHandler() from [Topic] attributes) and then POSTs each message to the matching endpoint. Your response decides the outcome: 2xx = success, RETRY status or 5xx = redeliver, DROP = discard (to a dead-letter topic if configured). Delivery is at least once, so handlers must be idempotent.
DaprClient.InvokeMethodAsync or an HttpClient from DaprClient.CreateInvokeHttpClient("pricing") goes app -> local sidecar -> remote sidecar -> remote app. Sidecars authenticate each other with certificates issued by Sentry (mTLS) and add traceparent. A Resiliency resource defines timeouts, retries and circuit breakers per target. Do not also stack Polly retries on the same call, or retries multiply.
Dapr.Workflow runs orchestrations as replayed code (like Durable Functions): the orchestrator must be deterministic, activities do the I/O. As of the 1.16 release (September 2025) the .NET workflow SDK was marked stable, and later releases continue on a roughly quarterly cadence; check the current supported versions before you pin one.
| Cost | Detail |
|---|---|
| Latency | One or two extra local hops per call; low single-digit ms |
| Resources | A sidecar per replica (tens of MB of memory) |
| Operations | Control plane upgrades, certificate rotation, version skew between runtime and SDK |
| Debugging | Failures can be in your app, the sidecar or the component; you need sidecar logs too |
dapr init, and start an API with dapr run --app-id orders --app-port 5000 -- dotnet run.DaprClient.PublishEventAsync and receive it in a [Topic] endpoint; return 500 and watch redelivery.HttpClient call versus Dapr service invocation with a small load test.A minimal .NET 10 API that publishes and subscribes through Dapr, plus the component that binds pubsub to Azure Service Bus.
// Program.cs (orders-api)
using Dapr;
using Dapr.Client;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDaprClient(); // DaprClient talks to the local sidecar
var app = builder.Build();
app.UseCloudEvents(); // unwraps the CloudEvents envelope
app.MapSubscribeHandler(); // serves GET /dapr/subscribe from [Topic] metadata
app.MapPost("/orders", async (PlaceOrder cmd, DaprClient dapr, CancellationToken ct) =>
{
var evt = new OrderPlaced(Guid.NewGuid(), cmd.Sku, cmd.Quantity);
// No Service Bus SDK here: the component decides the broker.
await dapr.PublishEventAsync("pubsub", "orders", evt, ct);
return Results.Accepted($"/orders/{evt.OrderId}", evt);
});
// The sidecar POSTs each message here; a non-2xx response causes redelivery.
app.MapPost("/handlers/order-placed", [Topic("pubsub", "orders")] async (
OrderPlaced evt, DaprClient dapr, CancellationToken ct) =>
{
// Idempotency: at-least-once delivery, so skip events already handled.
var key = $"processed-{evt.OrderId}";
if (await dapr.GetStateAsync<bool>("statestore", key, cancellationToken: ct)) return Results.Ok();
// ... do the work ...
await dapr.SaveStateAsync("statestore", key, true, cancellationToken: ct);
return Results.Ok();
});
app.Run();
public sealed record PlaceOrder(string Sku, int Quantity);
public sealed record OrderPlaced(Guid OrderId, string Sku, int Quantity);
# components/pubsub.yaml - swap type to pubsub.redis for local development
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: pubsub
spec:
type: pubsub.azure.servicebus.topics
version: v1
metadata:
- name: namespaceName
value: sb-orders-prod.servicebus.windows.net
- name: azureClientId # user-assigned managed identity, no connection string
value: 00000000-0000-0000-0000-000000000000
dapr run --app-id orders-api --app-port 5080 --resources-path ./components -- dotnet run
secretKeyRef to a secret store such as Key Vault.daprd logs. Instead: Check sidecar logs and the Dapr dashboard first when messages do not arrive.Dapr is an abstraction trade: you exchange the depth of each vendor SDK for one consistent API across languages and backends, plus free mTLS, tracing and resiliency between services. That trade pays off when the organisation is polyglot, runs in more than one environment, or wants actors and workflow as a platform capability. For an all-.NET Azure shop, the equivalent is usually Azure SDKs + Aspire for local orchestration + the standard resilience handler, with fewer moving parts.
What you give up is concrete. Through the generic pub/sub API you lose or must reach through metadata for Service Bus features such as sessions for ordered processing, scheduled enqueue time, deferral and fine-grained dead-letter handling; through the state API you lose Cosmos DB's rich queries and change feed; and the sidecar adds roughly a millisecond or two per hop and tens of MB per replica. Where it shines: a [logistics or IoT] platform with Go, Python and .NET services sharing one messaging model, an ISV that must deploy to customers' AKS, EKS or on-premises clusters, or a team that needs durable workflows or virtual actors without adopting Orleans or Durable Functions. Where it hurts: latency-sensitive trading or payments hot paths, and small teams who would rather debug one SDK than an app, a sidecar and a component.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
| Dapr | Polyglot, multi-cloud, Container Apps already | Sidecar hop, runtime upgrades, narrower APIs | Single-language single-cloud team |
| Native Azure SDKs + Aspire | All-.NET on Azure | Vendor-specific code, more wiring per service | You must run on several clouds |
| MassTransit / NServiceBus | Rich messaging patterns (sagas, outbox) in .NET | Library learning curve, commercial licence for some | You need cross-language semantics |
How to assess it: run a two-week spike on one service, then compare p99 latency with and without the sidecar under realistic load, count infrastructure code removed, list the broker features you had to give up, and ask the on-call engineers how long it took them to diagnose a deliberately broken component. Pin and upgrade runtime and SDK versions together within Dapr's supported window.
There are three styles. HTTP/JSON is universal and easy to debug; in .NET use IHttpClientFactory with AddStandardResilienceHandler for timeouts, retries and a circuit breaker. gRPC gives strict Protobuf contracts, smaller payloads, streaming and deadlines over HTTP/2, which suits high-volume internal calls, but needs layer 7 load balancing. Messaging (Azure Service Bus) removes temporal coupling: the receiver can be down or slow and the work still completes, at the cost of eventual consistency and idempotent consumers.
I choose per interaction: if the caller needs an answer to continue, call synchronously; if it is a command or an event that can finish later, send a message. For security, each service authenticates with managed identity to get an Entra ID token the callee validates, and mTLS from a mesh or platform encrypts the hop. The trade-off: every synchronous hop multiplies latency and failure.
A queue is point-to-point: a producer sends a message and exactly one consumer processes it. A topic is publish/subscribe: each subscription gets its own copy, so billing, email and analytics can all react to one OrderPlaced event.
The trade-off: you lose the immediate answer. If the caller needs the result to continue, a direct HTTP call is simpler.
Integrations come in two halves:
Aspire.Hosting.*, in the AppHost) model a resource: run SQL Server or Redis as a container, or generate Bicep for an Azure resource such as Service Bus or Storage.Aspire.*, in the service) register the SDK client in DI from a named connection string, plus health checks, OpenTelemetry and retries.For Azure, AddAzureServiceBus("messaging") either runs an emulator locally (RunAsEmulator()), provisions a real resource in your subscription during aspire run, or points at an existing one. Deployed apps connect with managed identity. ConfigureInfrastructure lets you change the generated Bicep.
The trade-off: consistent, observable clients with very little code, versus an extra package layer whose defaults you must know and keep up to date.
How to tell it (STAR)
**S:** We had moved [four] services to Dapr pub/sub, and after one release fulfilment stopped receiving orders without a single error. **T:** I was asked to find why messages piled up on the topic. **A:** I went to the sidecar logs rather than the app logs and saw that fulfilment had registered no subscriptions: the subscribe endpoint was missing and the component was scoped to the wrong apps. I fixed both, then added a pipeline smoke test that publishes and asserts receipt, and an alert on subscription backlog. **R:** The [12,000]-message backlog drained in [20 minutes], and we have had [no] silent delivery failures since.
Last updated 23 Nov 2026.