dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.55k stars 389 forks source link

How can I add project without endpoints with Dapr sidecar? #3687

Open dusan-tkac-bhp opened 4 months ago

dusan-tkac-bhp commented 4 months ago

Hello!

This used to work in preview 4 but stopped in preview 5.

I have a project which does not have any endpoints. It uses SDK to monitor storage queue (no Dapr bindings), it doesn't use any Dapr components, it just uses Dapr ActorProxy to invoke methods on actor instances. Actors are hosted by a different project.

I can run this project with Dapr sidecar from command line from within project's directory like this (no app port): dapr run --app-id cloud-runs-controller -- dotnet run

In preview 5, when I add the project to Aspire host, its Dapr sidecar fails to start with error

Failed to create resource package-event-processor-dapr-cli
System.InvalidOperationException: The endpoint `http` is not allocated for the resource `package-event-processor`.
   at Aspire.Hosting.ApplicationModel.EndpointReference.get_AllocatedEndpoint() in /_/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs:line 96
   at Aspire.Hosting.ApplicationModel.EndpointReference.get_Host() in /_/src/Aspire.Hosting/ApplicationModel/EndpointReference.cs:line 78
   at Aspire.Hosting.Dapr.DaprDistributedApplicationLifecycleHook.<>c__DisplayClass6_1.<BeforeStartAsync>b__9(IList`1 updatedArgs) in /_/src/Aspire.Hosting.Dapr/DaprDistributedApplicationLifecycleHook.cs:line 194
   at Aspire.Hosting.ApplicationModel.CommandLineArgsCallbackAnnotation.<>c__DisplayClass1_0.<.ctor>b__0(CommandLineArgsCallbackContext c) in /_/src/Aspire.Hosting/ApplicationModel/CommandLineArgsCallbackAnnotation.cs:line 32
   at Aspire.Hosting.Dcp.ApplicationExecutor.CreateExecutableAsync(AppResource er, ILogger resourceLogger, CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs:line 1194
   at Aspire.Hosting.Dcp.ApplicationExecutor.<CreateExecutablesAsync>g__CreateExecutableAsyncCore|53_0(AppResource cr, CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs:line 1134

Code that adds the project to Apire host:

builder.AddProject<Projects.PackageEventProcessor>("package-event-processor")
    .WithDaprSidecar(new DaprSidecarOptions
    {
        AppId = "cloud-runs-controller",
        ResourcesPaths = ImmutableHashSet.Create(@"..\resources"), // technically not needed

        // following is ok for local development with minimal logging
        EnableApiLogging = false,
        EnableAppHealthCheck = false,
        EnableProfiling = false,
        LogLevel = "warn",
        AppHealthProbeInterval = 60,
    });
davidfowl commented 4 months ago

This no longer works, and I'm not sure you can work around it without adding an endpoint to your application called http.

This is a regression we should fix.

dusan-tkac-bhp commented 4 months ago

Thank you!

I've added http endpoint to the app for now.