This is seventh post of the series: .NET Microservice with ABP
Posts in the Series
Part 3. Administration Service
Part 7. Yarp and Tye (this post)
Part 8. Identity server and Angular App
Table of Contents
Tye
Lets init the tye.
Install tye
dotnet tool install -g Microsoft.Tye --version "0.11.0-alpha.22111.1"
Init Tye
tye init --force
This will generate a tye.yaml
file.
name: tasky
services:
- name: tasky-identityserver
project: apps/Tasky.IdentityServer/Tasky.IdentityServer.csproj
bindings:
- protocol: https
port: 7000
- name: tasky-gateway
project: gateway/Tasky.Gateway/Tasky.Gateway.csproj
bindings:
- protocol: https
port: 7500
- name: tasky-administrationservice-httpapi-host
project: services/administration/host/Tasky.AdministrationService.HttpApi.Host/Tasky.AdministrationService.HttpApi.Host.csproj
bindings:
- protocol: https
port: 7001
- name: tasky-identityservice-httpapi-host
project: services/identity/host/Tasky.IdentityService.HttpApi.Host/Tasky.IdentityService.HttpApi.Host.csproj
bindings:
- protocol: https
port: 7002
- name: tasky-saasservice-httpapi-host
project: services/saas/host/Tasky.SaaSService.HttpApi.Host/Tasky.SaaSService.HttpApi.Host.csproj
bindings:
- protocol: https
port: 7003
Run Tye
tye run --watch
Yarp
Yarp is our proxy server which will redirect the request to other services. So lets update the Tasky.Gateway
.
Install nuget
<PackageReference Include="Yarp.ReverseProxy" Version="1.0.0" />
Update the Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddReverseProxy()
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
var app = builder.Build();
app.MapReverseProxy();
app.Run();
Update appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ReverseProxy": {
"Routes": {
"main": {
"ClusterId": "main",
"Match": {
"Path": "{**catch-all}"
}
},
"identity": {
"ClusterId": "identity",
"Match": {
"Path": "/api/identity/{*any}"
}
},
"account": {
"ClusterId": "account",
"Match": {
"Path": "/api/account/{*any}"
}
},
"saas": {
"ClusterId": "saas",
"Match": {
"Path": "/api/multi-tenancy/{*any}"
}
}
},
"Clusters": {
"main": {
"Destinations": {
"main": {
"Address": "https://localhost:7001"
}
}
},
"identity": {
"Destinations": {
"identity": {
"Address": "https://localhost:7002"
}
}
},
"account": {
"Destinations": {
"account": {
"Address": "https://localhost:7002"
}
}
},
"saas": {
"Destinations": {
"saas": {
"Address": "https://localhost:7003"
}
}
}
}
}
}
Related Posts
Migrating Tye to Aspire
In this post we will see how to migrate the Tye to Aspire
7/17/2024
.Net Microservice template with ABP
In this post I will show you how to create ABP microservice using a dotnet new template.
2/18/2023
Migrating Identity Service to OpenIddict Module
In this post we will see how to replace Identity server with OpenIddict in our microservice
12/5/2022