- Published on
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
1dotnet tool install -g Microsoft.Tye --version "0.11.0-alpha.22111.1"
Init Tye
1tye init --force
This will generate a tye.yaml
file.
1name: tasky 2services: 3- name: tasky-identityserver 4 project: apps/Tasky.IdentityServer/Tasky.IdentityServer.csproj 5 bindings: 6 - protocol: https 7 port: 7000 8- name: tasky-gateway 9 project: gateway/Tasky.Gateway/Tasky.Gateway.csproj 10 bindings: 11 - protocol: https 12 port: 7500 13- name: tasky-administrationservice-httpapi-host 14 project: services/administration/host/Tasky.AdministrationService.HttpApi.Host/Tasky.AdministrationService.HttpApi.Host.csproj 15 bindings: 16 - protocol: https 17 port: 7001 18- name: tasky-identityservice-httpapi-host 19 project: services/identity/host/Tasky.IdentityService.HttpApi.Host/Tasky.IdentityService.HttpApi.Host.csproj 20 bindings: 21 - protocol: https 22 port: 7002 23- name: tasky-saasservice-httpapi-host 24 project: services/saas/host/Tasky.SaaSService.HttpApi.Host/Tasky.SaaSService.HttpApi.Host.csproj 25 bindings: 26 - protocol: https 27 port: 7003
Run Tye
1tye run --watch
Yarp
Yarp is our proxy server which will redirect the request to other services. So lets update the Tasky.Gateway
.
Install nuget
1<PackageReference Include="Yarp.ReverseProxy" Version="1.0.0" />
Update the Program.cs
1var builder = WebApplication.CreateBuilder(args); 2builder.Services.AddReverseProxy() 3 .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy")); 4var app = builder.Build(); 5app.MapReverseProxy(); 6app.Run();
Update appsettings.json
1{ 2 "Logging": { 3 "LogLevel": { 4 "Default": "Information", 5 "Microsoft.AspNetCore": "Warning" 6 } 7 }, 8 "AllowedHosts": "*", 9 "ReverseProxy": { 10 "Routes": { 11 "main": { 12 "ClusterId": "main", 13 "Match": { 14 "Path": "{**catch-all}" 15 } 16 }, 17 "identity": { 18 "ClusterId": "identity", 19 "Match": { 20 "Path": "/api/identity/{*any}" 21 } 22 }, 23 "account": { 24 "ClusterId": "account", 25 "Match": { 26 "Path": "/api/account/{*any}" 27 } 28 }, 29 "saas": { 30 "ClusterId": "saas", 31 "Match": { 32 "Path": "/api/multi-tenancy/{*any}" 33 } 34 } 35 }, 36 "Clusters": { 37 "main": { 38 "Destinations": { 39 "main": { 40 "Address": "https://localhost:7001" 41 } 42 } 43 }, 44 "identity": { 45 "Destinations": { 46 "identity": { 47 "Address": "https://localhost:7002" 48 } 49 } 50 }, 51 "account": { 52 "Destinations": { 53 "account": { 54 "Address": "https://localhost:7002" 55 } 56 } 57 }, 58 "saas": { 59 "Destinations": { 60 "saas": { 61 "Address": "https://localhost:7003" 62 } 63 } 64 } 65 } 66 } 67}