Microsoft.Extensions.ServiceDiscovery.Yarp 8.0.0-preview.3.24105.21

Prefix Reserved
This is a prerelease version of Microsoft.Extensions.ServiceDiscovery.Yarp.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Microsoft.Extensions.ServiceDiscovery.Yarp --version 8.0.0-preview.3.24105.21                
NuGet\Install-Package Microsoft.Extensions.ServiceDiscovery.Yarp -Version 8.0.0-preview.3.24105.21                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery.Yarp" Version="8.0.0-preview.3.24105.21" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.Extensions.ServiceDiscovery.Yarp --version 8.0.0-preview.3.24105.21                
#r "nuget: Microsoft.Extensions.ServiceDiscovery.Yarp, 8.0.0-preview.3.24105.21"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Microsoft.Extensions.ServiceDiscovery.Yarp as a Cake Addin
#addin nuget:?package=Microsoft.Extensions.ServiceDiscovery.Yarp&version=8.0.0-preview.3.24105.21&prerelease

// Install Microsoft.Extensions.ServiceDiscovery.Yarp as a Cake Tool
#tool nuget:?package=Microsoft.Extensions.ServiceDiscovery.Yarp&version=8.0.0-preview.3.24105.21&prerelease                

Microsoft.Extensions.ServiceDiscovery.Yarp

The Microsoft.Extensions.ServiceDiscovery.Yarp library adds support for resolving endpoints for YARP clusters, by implementing a YARP destination resolver.

Usage

Resolving YARP cluster destinations using Service Discovery

The IReverseProxyBuilder.AddServiceDiscoveryDestinationResolver() extension method configures a YARP destination resolver. To use this method, you must also configure YARP itself as described in the YARP documentation, and you must configure .NET Service Discovery via the Microsoft.Extensions.ServiceDiscovery library.

Direct HTTP forwarding using Service Discovery Forwarding HTTP requests using IHttpForwarder

YARP supports direct forwarding of specific requests using the IHttpForwarder interface. This, too, can benefit from service discovery using the Microsoft.Extensions.ServiceDiscovery library. To take advantage of service discovery when using YARP Direct Forwarding, use the IServiceCollection.AddHttpForwarderWithServiceDiscovery method.

For example, consider the following .NET Aspire application:

var builder = WebApplication.CreateBuilder(args);

// Configure service discovery
builder.Services.AddServiceDiscovery();

// Add YARP Direct Forwarding with Service Discovery support
builder.Services.AddHttpForwarderWithServiceDiscovery();

// ... other configuration ...

var app = builder.Build();

// ... other configuration ...

// Map a Direct Forwarder which forwards requests to the resolved "catalogservice" endpoints
app.MapForwarder("/catalog/images/{id}", "http://catalogservice", "/api/v1/catalog/items/{id}/image");

app.Run();

In the above example, the YARP Direct Forwarder will resolve the catalogservice using service discovery, forwarding request sent to the /catalog/images/{id} endpoint to the destination path on the resolved endpoints.

Feedback & contributing

https://github.com/dotnet/aspire

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Microsoft.Extensions.ServiceDiscovery.Yarp:

Package Downloads
Aspirant.Hosting.Yarp

A custom YARP ingress resource for .NET Aspire App Host projects.

GitHub repositories (5)

Showing the top 5 popular GitHub repositories that depend on Microsoft.Extensions.ServiceDiscovery.Yarp:

Repository Stars
dotnet/eShop
A reference .NET application implementing an eCommerce site
dotnet/aspire-samples
abpframework/eShopOnAbp
Reference microservice solution built with the ABP Framework and .NET, runs on Kubernetes with Helm configuration, includes API Gateways, Angular and ASP.NET Core MVC applications, PostgreSQL and MongoDB databases
Azure-Samples/eShopOnAzure
A variant of https://github.com/dotnet/eShop that uses Azure services
dotnet-presentations/eshop-app-workshop
This workshop will teach you ASP.NET Core & .NET Aspire by building the product catalog & order placement features of the eShop reference application.
Version Downloads Last updated
9.0.0 2,945 11/12/2024
9.0.0-rc.1.24511.1 3,599 10/15/2024
8.2.2 4,500 10/24/2024
8.2.1 10,591 9/26/2024
8.2.0 18,309 8/29/2024
8.1.0 15,231 7/23/2024
8.0.2 10,865 6/28/2024
8.0.1 30,432 5/21/2024
8.0.0 5,506 5/21/2024
8.0.0-preview.7.24251.11 6,696 5/7/2024
8.0.0-preview.6.24214.1 7,643 4/23/2024
8.0.0-preview.5.24201.12 5,948 4/9/2024
8.0.0-preview.4.24156.9 8,050 3/12/2024
8.0.0-preview.3.24105.21 6,229 2/13/2024
8.0.0-preview.2.23619.3 8,288 12/20/2023
8.0.0-preview.1.23557.2 8,348 11/14/2023