Skip to content

Fix WebAPI sample to use embedded gRPC sidecar#519

Closed
sophiatev with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-webapi-schedule-new-process-order
Closed

Fix WebAPI sample to use embedded gRPC sidecar#519
sophiatev with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-webapi-schedule-new-process-order

Conversation

Copilot AI commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

The WebAPI sample failed with "gRPC server for Durable Task gRPC worker is unavailable" because it expected an external sidecar that wasn't running.

Changes

  • Embedded sidecar: Integrated InProcessTestHost's in-memory orchestration service directly into the WebAPI host
  • Dual-port Kestrel config: REST API on port 8080 (HTTP/1.1), gRPC sidecar on port 8081 (HTTP/2)
  • Project references: Switched from NuGet packages to p2p references (consistent with other samples)
  • Cleaned up launchSettings.json: Removed obsolete sidecar address config

Key code changes

// Configure two endpoints
builder.WebHost.ConfigureKestrel(options =>
{
    options.ListenAnyIP(8080, o => o.Protocols = HttpProtocols.Http1);  // REST
    options.ListenAnyIP(8081, o => o.Protocols = HttpProtocols.Http2); // gRPC
});

// Embedded in-memory orchestration service
InMemoryOrchestrationService orchestrationService = new();
builder.Services.AddSingleton<IOrchestrationService>(orchestrationService);
builder.Services.AddSingleton<TaskHubGrpcServer>();

// Worker/client connect to self
GrpcChannel grpcChannel = GrpcChannel.ForAddress("http://localhost:8081");
builder.Services.AddDurableTaskWorker(b => b.UseGrpc(grpcChannel));
builder.Services.AddDurableTaskClient(b => b.UseGrpc(grpcChannel));

Sample now works out of the box without external dependencies.

Original prompt

This section details on the original issue you should resolve

<issue_title>DurableTaskClient.ScheduleNewProcessOrderOrchestratorInstanceAsync() was failed in the sample 'WebAPI'</issue_title>
<issue_description>The sample 'WebAPI' keeps throwing the following message hence the calling of durableTaskClient.ScheduleNewProcessOrderOrchestratorInstanceAsync() is always failed.

info: Microsoft.DurableTask[3] The gRPC server for Durable Task gRPC worker is unavailable. Will continue retrying.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 2, 2025 22:54
Co-authored-by: sophiatev <38052607+sophiatev@users.noreply.github.com>
Co-authored-by: sophiatev <38052607+sophiatev@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix DurableTaskClient.ScheduleNewProcessOrderOrchestratorInstanceAsync failure Fix WebAPI sample to use embedded gRPC sidecar Dec 2, 2025
Copilot AI requested a review from sophiatev December 2, 2025 23:06
@torosent
torosent marked this pull request as ready for review December 3, 2025 00:02
Copilot AI review requested due to automatic review settings December 3, 2025 00:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a broken WebAPI sample by embedding an in-memory gRPC sidecar directly into the application, eliminating the need for an external sidecar process. The sample previously failed with "gRPC server for Durable Task gRPC worker is unavailable" because it expected an external dependency that wasn't configured.

Key Changes:

  • Integrated InProcessTestHost's in-memory orchestration service to provide an embedded gRPC sidecar
  • Configured Kestrel with dual endpoints: port 8080 for REST API (HTTP/1.1) and port 8081 for gRPC sidecar (HTTP/2)
  • Switched from NuGet package references to project-to-project references, consistent with other samples

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
samples/WebAPI/WebAPI.csproj Added project references for Client.Grpc, Worker.Grpc, and InProcessTestHost; commented out package references
samples/WebAPI/Properties/launchSettings.json Simplified launch configuration by removing IIS Express profile, obsolete sidecar address environment variable, and unnecessary browser launch settings
samples/WebAPI/Program.cs Implemented embedded gRPC sidecar with dual-port Kestrel configuration, in-memory orchestration service, and proper service registrations for TaskHubGrpcServer

Comment thread samples/WebAPI/Program.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@torosent torosent closed this Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DurableTaskClient.ScheduleNewProcessOrderOrchestratorInstanceAsync() was failed in the sample 'WebAPI'

4 participants