Consider this to be a .NET companion to the [Dapr Self-Hosted with Docker Guide]({{ ref self-hosted-overview.md }})).
The Dapr CLI provides you with a good base to work from by initializing a local redis container, zipkin container, the placement service, and component manifests for redis. This will enable you to work with the following building blocks on a fresh install with no additional setup:
You can run .NET services with dapr run
as your strategy for developing locally. Plan on running one of these commands per-service in order to launch your application.
For each service you need to choose:
app-id
)port
)You also should have decided on where you are storing components (components-path
).
The following command can be run from multiple terminals to launch each service, with the respective values substituted.
dapr run --app-id <app-id> --app-port <port> --components-path <components-path> -- dotnet run -p <project> --urls http://localhost:<port>
Explanation: this command will use dapr run
to launch each service and its sidecar. The first half of the command (before --
) passes required configuration to the Dapr CLI. The second half of the command (after --
) passes required configuration to the dotnet run
command.
--urls http://localhost:<port>
will configure ASP.NET Core to listen for traffic on the provided port. Using configuration at the commandline is a more flexible approach than hardcoding a listening port elsewhere.If any of your services do not accept HTTP traffic, then modify the command above by removing the --app-port
and --urls
arguments.
If you need to debug, then use the attach feature of your debugger to attach to one of the running processes.
If you want to scale up this approach, then consider building a script which automates this process for your whole application.