Skip to main content
net8.0

YARP support for .NET Aspire.

Published
Jun 10, 2025
1y ago
Total Downloads
671.2K
671,194

Deprecated Package Version

Reason: Other, Legacy

This version is out of support and is no longer maintained. Please upgrade to the latest version. See our support policy for details: https://aka.ms/dotnet/aspire/support

Install

dotnet add package Aspire.Hosting.Yarp --version 9.3.1-preview.1.25305.6
ProductVersions
.NET
net8.0

README

Aspire.Hosting.Yarp library

Provides extension methods and resource definitions for a .NET Aspire AppHost to configure a YARP instance.

Getting started

Install the package

In your AppHost project, install the .NET Aspire YARP Hosting library with NuGet:

dotnet add package Aspire.Hosting.Yarp

Usage example

Then, in the Program.cs file of AppHost, add a YARP resource and provide the configuration file using the following methods:

var catalogService = builder.AddProject<Projects.CatalogService>("catalogservice")
                            [...];
var basketService = builder.AddProject<Projects.BasketService>("basketservice")
                            [...];

builder.AddYarp("apigateway")
       .WithConfigFile("yarp.json")
       .WithReference(basketService)
       .WithReference(catalogService);

The yarp.json configuration file can use the referenced service like this:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Information"
    }
  },
  "AllowedHosts": "*",
  "ReverseProxy": {
    "Routes": {
      "catalog": {
        "ClusterId": "catalog",
        "Match": {
          "Path": "/catalog/{**catch-all}"
        },
        "Transforms": [
          { "PathRemovePrefix": "/catalog" }
        ]
      },
      "basket": {
        "ClusterId": "basket",
        "Match": {
          "Path": "/basket/{**catch-all}"
        },
        "Transforms": [
          { "PathRemovePrefix": "/basket" }
        ]
      }
    },
    "Clusters": {
      "catalog": {
        "Destinations": {
          "catalog": {
            "Address": "http://catalogservice",
          }
        }
      },
      "basket": {
        "Destinations": {
          "basket": {
            "Address": "http://basketservice",
          }
        }
      }
    }
  }
}

Additional documentation

Feedback & contributing

https://github.com/dotnet/aspire

Changes from Previous Version

No structural changes between v9.3.0-preview.1.25265.20 and v9.3.1-preview.1.25305.6.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.NuGet marks this package as deprecated. Review the publisher's migration guidance before adopting it.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.The published metadata declares 23 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.