Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 29 additions & 15 deletions Aspire.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CatalogService", "playgroun
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasketService", "playground\TestShop\BasketService\BasketService.csproj", "{3FC74EA6-D554-4A87-AED5-A08FE407BBF4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiGateway", "playground\TestShop\ApiGateway\ApiGateway.csproj", "{934625C7-243F-4659-9421-515301CF0263}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspire.StackExchange.Redis", "src\Components\Aspire.StackExchange.Redis\Aspire.StackExchange.Redis.csproj", "{7D4A7A84-B297-4777-9E2A-D8B1C427CAC7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Components", "Components", "{27381127-6C45-4B4C-8F18-41FF48DFE4B2}"
Expand Down Expand Up @@ -660,6 +658,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.Azure.Npgsql.EntityF
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.Components.Common.Tests", "tests\Aspire.Components.Common.Tests\Aspire.Components.Common.Tests.csproj", "{30950CEB-2232-F9FC-04FF-ADDCB8AC30A7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.Hosting.Yarp", "src\Aspire.Hosting.Yarp\Aspire.Hosting.Yarp.csproj", "{A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.Hosting.Azure.ContainerRegistry", "src\Aspire.Hosting.Azure.ContainerRegistry\Aspire.Hosting.Azure.ContainerRegistry.csproj", "{6CBA29C8-FF78-4ABC-BEFA-2A53CB4DB2A3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.Hosting.Azure.AppService", "src\Aspire.Hosting.Azure.AppService\Aspire.Hosting.Azure.AppService.csproj", "{5DDF8E89-FBBD-4A6F-BF32-7D2140724941}"
Expand All @@ -670,6 +670,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AzureAppService.ApiService"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AzureAppService.AppHost", "playground\AzureAppService\AzureAppService.AppHost\AzureAppService.AppHost.csproj", "{2C879943-DF34-44FA-B2C3-29D97F24DD76}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.Hosting.Yarp.Tests", "tests\Aspire.Hosting.Yarp.Tests\Aspire.Hosting.Yarp.Tests.csproj", "{2652012B-C28B-461B-93F6-9D1C8247EAB7}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SqlServerScript", "SqlServerScript", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppHost1", "playground\SqlServerScript\AppHost1\AppHost1.csproj", "{3928CF69-B803-43A2-8AE5-5E29CB3E8D24}"
Expand Down Expand Up @@ -750,18 +751,6 @@ Global
{3FC74EA6-D554-4A87-AED5-A08FE407BBF4}.Release|x64.Build.0 = Release|Any CPU
{3FC74EA6-D554-4A87-AED5-A08FE407BBF4}.Release|x86.ActiveCfg = Release|Any CPU
{3FC74EA6-D554-4A87-AED5-A08FE407BBF4}.Release|x86.Build.0 = Release|Any CPU
{934625C7-243F-4659-9421-515301CF0263}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{934625C7-243F-4659-9421-515301CF0263}.Debug|Any CPU.Build.0 = Debug|Any CPU
{934625C7-243F-4659-9421-515301CF0263}.Debug|x64.ActiveCfg = Debug|Any CPU
{934625C7-243F-4659-9421-515301CF0263}.Debug|x64.Build.0 = Debug|Any CPU
{934625C7-243F-4659-9421-515301CF0263}.Debug|x86.ActiveCfg = Debug|Any CPU
{934625C7-243F-4659-9421-515301CF0263}.Debug|x86.Build.0 = Debug|Any CPU
{934625C7-243F-4659-9421-515301CF0263}.Release|Any CPU.ActiveCfg = Release|Any CPU
{934625C7-243F-4659-9421-515301CF0263}.Release|Any CPU.Build.0 = Release|Any CPU
{934625C7-243F-4659-9421-515301CF0263}.Release|x64.ActiveCfg = Release|Any CPU
{934625C7-243F-4659-9421-515301CF0263}.Release|x64.Build.0 = Release|Any CPU
{934625C7-243F-4659-9421-515301CF0263}.Release|x86.ActiveCfg = Release|Any CPU
{934625C7-243F-4659-9421-515301CF0263}.Release|x86.Build.0 = Release|Any CPU
{7D4A7A84-B297-4777-9E2A-D8B1C427CAC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7D4A7A84-B297-4777-9E2A-D8B1C427CAC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D4A7A84-B297-4777-9E2A-D8B1C427CAC7}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -3894,6 +3883,18 @@ Global
{30950CEB-2232-F9FC-04FF-ADDCB8AC30A7}.Release|x64.Build.0 = Release|Any CPU
{30950CEB-2232-F9FC-04FF-ADDCB8AC30A7}.Release|x86.ActiveCfg = Release|Any CPU
{30950CEB-2232-F9FC-04FF-ADDCB8AC30A7}.Release|x86.Build.0 = Release|Any CPU
{A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Debug|x64.ActiveCfg = Debug|Any CPU
{A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Debug|x64.Build.0 = Debug|Any CPU
{A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Debug|x86.ActiveCfg = Debug|Any CPU
{A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Debug|x86.Build.0 = Debug|Any CPU
{A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Release|Any CPU.Build.0 = Release|Any CPU
{A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Release|x64.ActiveCfg = Release|Any CPU
{A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Release|x64.Build.0 = Release|Any CPU
{A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Release|x86.ActiveCfg = Release|Any CPU
{A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF}.Release|x86.Build.0 = Release|Any CPU
{6CBA29C8-FF78-4ABC-BEFA-2A53CB4DB2A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CBA29C8-FF78-4ABC-BEFA-2A53CB4DB2A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CBA29C8-FF78-4ABC-BEFA-2A53CB4DB2A3}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -3942,6 +3943,18 @@ Global
{2C879943-DF34-44FA-B2C3-29D97F24DD76}.Release|x64.Build.0 = Release|Any CPU
{2C879943-DF34-44FA-B2C3-29D97F24DD76}.Release|x86.ActiveCfg = Release|Any CPU
{2C879943-DF34-44FA-B2C3-29D97F24DD76}.Release|x86.Build.0 = Release|Any CPU
{2652012B-C28B-461B-93F6-9D1C8247EAB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2652012B-C28B-461B-93F6-9D1C8247EAB7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2652012B-C28B-461B-93F6-9D1C8247EAB7}.Debug|x64.ActiveCfg = Debug|Any CPU
{2652012B-C28B-461B-93F6-9D1C8247EAB7}.Debug|x64.Build.0 = Debug|Any CPU
{2652012B-C28B-461B-93F6-9D1C8247EAB7}.Debug|x86.ActiveCfg = Debug|Any CPU
{2652012B-C28B-461B-93F6-9D1C8247EAB7}.Debug|x86.Build.0 = Debug|Any CPU
{2652012B-C28B-461B-93F6-9D1C8247EAB7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2652012B-C28B-461B-93F6-9D1C8247EAB7}.Release|Any CPU.Build.0 = Release|Any CPU
{2652012B-C28B-461B-93F6-9D1C8247EAB7}.Release|x64.ActiveCfg = Release|Any CPU
{2652012B-C28B-461B-93F6-9D1C8247EAB7}.Release|x64.Build.0 = Release|Any CPU
{2652012B-C28B-461B-93F6-9D1C8247EAB7}.Release|x86.ActiveCfg = Release|Any CPU
{2652012B-C28B-461B-93F6-9D1C8247EAB7}.Release|x86.Build.0 = Release|Any CPU
{3928CF69-B803-43A2-8AE5-5E29CB3E8D24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3928CF69-B803-43A2-8AE5-5E29CB3E8D24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3928CF69-B803-43A2-8AE5-5E29CB3E8D24}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -4000,7 +4013,6 @@ Global
{C7B2309C-073A-4552-A508-A69768B64C6F} = {A68BA1A5-1604-433D-9778-DC0199831C2A}
{6D04BB34-1CC6-4FF3-A02A-1FFAC2A7A4F3} = {A68BA1A5-1604-433D-9778-DC0199831C2A}
{3FC74EA6-D554-4A87-AED5-A08FE407BBF4} = {A68BA1A5-1604-433D-9778-DC0199831C2A}
{934625C7-243F-4659-9421-515301CF0263} = {A68BA1A5-1604-433D-9778-DC0199831C2A}
{7D4A7A84-B297-4777-9E2A-D8B1C427CAC7} = {27381127-6C45-4B4C-8F18-41FF48DFE4B2}
{145E569B-633F-4FF0-B273-CB1D3B49B9F2} = {63BB22D3-0FAC-4E87-BF9D-9FA2441684C9}
{7570F683-EB48-467F-B1B1-70FF0153F52B} = {63BB22D3-0FAC-4E87-BF9D-9FA2441684C9}
Expand Down Expand Up @@ -4307,11 +4319,13 @@ Global
{192747A2-9338-DECF-5C8C-28EB8E13829B} = {27381127-6C45-4B4C-8F18-41FF48DFE4B2}
{8FCA0CFA-7823-6A2F-342A-107A994915B0} = {C424395C-1235-41A4-BF55-07880A04368C}
{30950CEB-2232-F9FC-04FF-ADDCB8AC30A7} = {C424395C-1235-41A4-BF55-07880A04368C}
{A3399DE9-AAB0-43EA-B99B-6A62ABBDD7BF} = {B80354C7-BE58-43F6-8928-9F3A74AB7F47}
{6CBA29C8-FF78-4ABC-BEFA-2A53CB4DB2A3} = {77CFE74A-32EE-400C-8930-5025E8555256}
{5DDF8E89-FBBD-4A6F-BF32-7D2140724941} = {77CFE74A-32EE-400C-8930-5025E8555256}
{2D9974C2-3AB2-FBFD-5156-080508BB7449} = {D173887B-AF42-4576-B9C1-96B9E9B3D9C0}
{A617DC84-65DA-41B5-B378-6C2F569CEE48} = {2D9974C2-3AB2-FBFD-5156-080508BB7449}
{2C879943-DF34-44FA-B2C3-29D97F24DD76} = {2D9974C2-3AB2-FBFD-5156-080508BB7449}
{2652012B-C28B-461B-93F6-9D1C8247EAB7} = {830A89EC-4029-4753-B25A-068BAE37DEC7}
{02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {D173887B-AF42-4576-B9C1-96B9E9B3D9C0}
{3928CF69-B803-43A2-8AE5-5E29CB3E8D24} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{E79A95EA-08D9-9947-377D-6F2213B36E1B} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
Expand Down
3 changes: 2 additions & 1 deletion playground/TestShop/TestShop.AppHost/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
builder.AddProject<Projects.OrderProcessor>("orderprocessor", launchProfileName: "OrderProcessor")
.WithReference(messaging).WaitFor(messaging);

builder.AddProject<Projects.ApiGateway>("apigateway")
builder.AddYarp("apigateway")
.WithConfigFile("yarp.json")
.WithReference(basketService)
.WithReference(catalogService);

Expand Down
3 changes: 1 addition & 2 deletions playground/TestShop/TestShop.AppHost/TestShop.AppHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
<AspireProjectOrPackageReference Include="Aspire.Hosting.RabbitMQ" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Redis" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.PostgreSQL" />

<ProjectReference Include="..\ApiGateway\ApiGateway.csproj" />
<AspireProjectOrPackageReference Include="Aspire.Hosting.Yarp" />
<ProjectReference Include="..\BasketService\BasketService.csproj" />
<ProjectReference Include="..\CatalogDb\CatalogDb.csproj" />
<ProjectReference Include="..\CatalogService\CatalogService.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
49 changes: 49 additions & 0 deletions playground/TestShop/TestShop.AppHost/yarp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"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",
"Health": "http://catalogservice/readiness"
}
}
},
"basket": {
"Destinations": {
"basket": {
"Address": "http://basketservice",
"Health": "http://basketservice/readiness"
}
}
}
}
}
}
1 change: 1 addition & 0 deletions spelling.dic
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ urls
kubernetes
Pgweb
elasticsearch
Yarp
20 changes: 20 additions & 0 deletions src/Aspire.Hosting.Yarp/Aspire.Hosting.Yarp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
<IsPackable>true</IsPackable>
<PackageTags>aspire integration hosting yarp reverse-proxy</PackageTags>
<Description>YARP support for .NET Aspire.</Description>
<EnablePackageValidation>false</EnablePackageValidation>
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
</PropertyGroup>

<PropertyGroup>
<MinCodeCoverage>0</MinCodeCoverage>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Aspire.Hosting\Aspire.Hosting.csproj" />
</ItemGroup>

</Project>
92 changes: 92 additions & 0 deletions src/Aspire.Hosting.Yarp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# 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](https://www.nuget.org):

```dotnetcli
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:

```csharp
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:

```json
{
"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

* https://learn.microsoft.com/dotnet/aspire/caching/stackexchange-redis-component
* https://learn.microsoft.com/dotnet/aspire/caching/stackexchange-redis-output-caching-component
* https://learn.microsoft.com/dotnet/aspire/caching/stackexchange-redis-distributed-caching-component

## Feedback & contributing

https://github.com/dotnet/aspire
13 changes: 13 additions & 0 deletions src/Aspire.Hosting.Yarp/YarpContainerImageTags.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Aspire.Hosting.Yarp;

internal static class YarpContainerImageTags
Copy link
Member

Choose a reason for hiding this comment

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

Seems like the other ones all have tags for each of these.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure to understand?

{
public const string Registry = "mcr.microsoft.com";

public const string Image = "dotnet/nightly/yarp";

public const string Tag = "2-preview";
}
18 changes: 18 additions & 0 deletions src/Aspire.Hosting.Yarp/YarpResource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Aspire.Hosting.ApplicationModel;

namespace Aspire.Hosting.Yarp;

/// <summary>
/// A resource that represents a YARP resource independent of the hosting model.
/// </summary>
/// <param name="name">The name of the resource.</param>
public class YarpResource(string name) : ContainerResource(name)
{
/// <summary>
/// File path of the config file for this YARP resource.
/// </summary>
internal string? ConfigFilePath { get; set; }
}
Loading