Skip to content

Commit

Permalink
Merge pull request #74 from antosubash/aspire-youtube
Browse files Browse the repository at this point in the history
aspire working
  • Loading branch information
antosubash authored Jul 17, 2024
2 parents 92f6412 + 54137da commit e72138f
Show file tree
Hide file tree
Showing 24 changed files with 270 additions and 40 deletions.
19 changes: 19 additions & 0 deletions src/Tasky.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var builder = DistributedApplication.CreateBuilder(args);

builder.AddProject<Projects.Tasky_AuthServer>("tasky-authserver", launchProfileName: "Tasky.AuthServer");

builder.AddProject<Projects.Tasky_Administration_HttpApi_Host>("tasky-administration-httpapi-host", launchProfileName: "Tasky.Administration.Host");

builder.AddProject<Projects.Tasky_IdentityService_HttpApi_Host>("tasky-identityservice-httpapi-host", launchProfileName: "Tasky.IdentityService.Host");

builder.AddProject<Projects.Tasky_Projects_HttpApi_Host>("tasky-projects-httpapi-host", launchProfileName: "Tasky.Projects.Host");

builder.AddProject<Projects.Tasky_SaaS_HttpApi_Host>("tasky-saas-httpapi-host", launchProfileName: "Tasky.SaaS.Host");

builder.AddProject<Projects.Tasky_Gateway>("tasky-gateway", launchProfileName: "Tasky.Gateway");

builder.AddProject<Projects.Tasky_Blazor_Server>("tasky-blazor-server", launchProfileName: "Tasky.Blazor.Server");

builder.AddProject<Projects.Tasky_Blazor>("tasky-blazor", launchProfileName: "Tasky.Blazor");

builder.Build().Run();
29 changes: 29 additions & 0 deletions src/Tasky.AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17166;http://localhost:15124",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21213",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22298"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15124",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19233",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20251"
}
}
}
}
27 changes: 27 additions & 0 deletions src/Tasky.AppHost/Tasky.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>0aae16e2-bc34-40f6-b9c4-10379cc46b10</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.0.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\services\administration\host\Tasky.Administration.HttpApi.Host\Tasky.Administration.HttpApi.Host.csproj" />
<ProjectReference Include="..\services\identity\host\Tasky.IdentityService.HttpApi.Host\Tasky.IdentityService.HttpApi.Host.csproj" />
<ProjectReference Include="..\services\projects\host\Tasky.Projects.HttpApi.Host\Tasky.Projects.HttpApi.Host.csproj" />
<ProjectReference Include="..\services\saas\host\Tasky.SaaS.HttpApi.Host\Tasky.SaaS.HttpApi.Host.csproj" />
<ProjectReference Include="..\apps\Tasky.AuthServer\Tasky.AuthServer.csproj" />
<ProjectReference Include="..\apps\Tasky.Blazor\Tasky.Blazor.csproj" />
<ProjectReference Include="..\apps\Tasky.Blazor.Server\Tasky.Blazor.Server.csproj" />
<ProjectReference Include="..\gateway\Tasky.Gateway\Tasky.Gateway.csproj" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions src/Tasky.AppHost/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions src/Tasky.AppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
13 changes: 13 additions & 0 deletions src/Tasky.sln
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tasky.Blazor", "apps\Tasky.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tasky.Blazor.Server", "apps\Tasky.Blazor.Server\Tasky.Blazor.Server.csproj", "{EB163A6D-3FE6-4C7D-9A7E-7F7044F7130F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tasky.AppHost", "Tasky.AppHost\Tasky.AppHost.csproj", "{8DB15713-440F-40DF-BAF3-F6A376F81CE0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tasky.ServiceDefaults", "shared\Tasky.ServiceDefaults\Tasky.ServiceDefaults.csproj", "{8506D754-AA5B-40FD-9788-D9BB513967B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -265,6 +269,14 @@ Global
{EB163A6D-3FE6-4C7D-9A7E-7F7044F7130F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB163A6D-3FE6-4C7D-9A7E-7F7044F7130F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB163A6D-3FE6-4C7D-9A7E-7F7044F7130F}.Release|Any CPU.Build.0 = Release|Any CPU
{8DB15713-440F-40DF-BAF3-F6A376F81CE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8DB15713-440F-40DF-BAF3-F6A376F81CE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8DB15713-440F-40DF-BAF3-F6A376F81CE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DB15713-440F-40DF-BAF3-F6A376F81CE0}.Release|Any CPU.Build.0 = Release|Any CPU
{8506D754-AA5B-40FD-9788-D9BB513967B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8506D754-AA5B-40FD-9788-D9BB513967B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8506D754-AA5B-40FD-9788-D9BB513967B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8506D754-AA5B-40FD-9788-D9BB513967B1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -313,6 +325,7 @@ Global
{5AC9119B-D456-45F6-80FA-D48B51BAEAED} = {79065DE8-D7FB-40A5-980B-A0841A208B38}
{56A6B29B-646F-4104-B389-0709DE9FC041} = {79065DE8-D7FB-40A5-980B-A0841A208B38}
{EB163A6D-3FE6-4C7D-9A7E-7F7044F7130F} = {79065DE8-D7FB-40A5-980B-A0841A208B38}
{8506D754-AA5B-40FD-9788-D9BB513967B1} = {140ED621-3D93-4523-8B62-BE6850E04698}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ECFA44F4-824C-4405-82F5-F62F2DCBCD5E}
Expand Down
1 change: 1 addition & 0 deletions src/apps/Tasky.AuthServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public async static Task<int> Main(string[] args)
{
Log.Information("Starting Tasky.AuthServer.");
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.Host.AddAppSettingsSecretsJson()
.UseAutofac()
.UseSerilog();
Expand Down
4 changes: 4 additions & 0 deletions src/apps/Tasky.AuthServer/Tasky.AuthServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@
<ProjectReference Include="..\..\shared\Tasky.Microservice.Shared\Tasky.Microservice.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\shared\Tasky.ServiceDefaults\Tasky.ServiceDefaults.csproj" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions src/apps/Tasky.Blazor.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public async static Task<int> Main(string[] args)
{
Log.Information("Starting web host.");
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.Host.AddAppSettingsSecretsJson()
.UseAutofac()
.UseSerilog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": "true",
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:5001/"
},
"Docker": {
Expand Down
4 changes: 4 additions & 0 deletions src/apps/Tasky.Blazor.Server/Tasky.Blazor.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,8 @@
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\shared\Tasky.ServiceDefaults\Tasky.ServiceDefaults.csproj" />
</ItemGroup>

</Project>
1 change: 0 additions & 1 deletion src/apps/Tasky.Blazor/Tasky.Blazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@
<PackageReference Include="Volo.Abp.TenantManagement.Blazor.WebAssembly" Version="8.0.2" />
<PackageReference Include="Volo.Abp.SettingManagement.Blazor.WebAssembly" Version="8.0.2" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions src/gateway/Tasky.Gateway/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.Services.AddReverseProxy()
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
var app = builder.Build();
Expand Down
4 changes: 4 additions & 0 deletions src/gateway/Tasky.Gateway/Tasky.Gateway.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
<PackageReference Include="Yarp.ReverseProxy" Version="2.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\shared\Tasky.ServiceDefaults\Tasky.ServiceDefaults.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public async static Task<int> Main(string[] args)
{
Log.Information("Starting web host.");
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.Host.AddAppSettingsSecretsJson()
.UseAutofac()
.UseSerilog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public async static Task<int> Main(string[] args)
{
Log.Information("Starting web host.");
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.Host.AddAppSettingsSecretsJson()
.UseAutofac()
.UseSerilog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public async static Task<int> Main(string[] args)
{
Log.Information("Starting web host.");
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.Host.AddAppSettingsSecretsJson()
.UseAutofac()
.UseSerilog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Tasky.Projects.DemoApp": {
"Tasky.Projects.Host": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\shared\Tasky.Hosting.Shared\Tasky.Hosting.Shared.csproj" />
<ProjectReference Include="..\..\src\Tasky.Projects.HttpApi\Tasky.Projects.HttpApi.csproj" />
<ProjectReference Include="..\..\src\Tasky.Projects.Application\Tasky.Projects.Application.csproj" />
<ProjectReference Include="..\..\src\Tasky.Projects.EntityFrameworkCore\Tasky.Projects.EntityFrameworkCore.csproj" />
Expand Down
1 change: 1 addition & 0 deletions src/services/saas/host/Tasky.SaaS.HttpApi.Host/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public async static Task<int> Main(string[] args)
{
Log.Information("Starting web host.");
var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.Host.AddAppSettingsSecretsJson()
.UseAutofac()
.UseSerilog();
Expand Down
3 changes: 3 additions & 0 deletions src/shared/Tasky.Hosting.Shared/Tasky.Hosting.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@
<PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" Version="8.0.2" />

</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Tasky.ServiceDefaults\Tasky.ServiceDefaults.csproj" />
</ItemGroup>
</Project>
118 changes: 118 additions & 0 deletions src/shared/Tasky.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.ServiceDiscovery;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;

namespace Microsoft.Extensions.Hosting;

// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
// This project should be referenced by each service project in your solution.
// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
public static class Extensions
{
public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder)
{
builder.ConfigureOpenTelemetry();

builder.AddDefaultHealthChecks();

builder.Services.AddServiceDiscovery();

builder.Services.ConfigureHttpClientDefaults(http =>
{
// Turn on resilience by default
http.AddStandardResilienceHandler();

// Turn on service discovery by default
http.AddServiceDiscovery();
});

// Uncomment the following to restrict the allowed schemes for service discovery.
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
// {
// options.AllowedSchemes = ["https"];
// });

return builder;
}

public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicationBuilder builder)
{
builder.Logging.AddOpenTelemetry(logging =>
{
logging.IncludeFormattedMessage = true;
logging.IncludeScopes = true;
});

builder.Services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation();
})
.WithTracing(tracing =>
{
tracing.AddAspNetCoreInstrumentation()
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
//.AddGrpcClientInstrumentation()
.AddHttpClientInstrumentation();
});

builder.AddOpenTelemetryExporters();

return builder;
}

private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostApplicationBuilder builder)
{
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);

if (useOtlpExporter)
{
builder.Services.AddOpenTelemetry().UseOtlpExporter();
}

// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
//{
// builder.Services.AddOpenTelemetry()
// .UseAzureMonitor();
//}

return builder;
}

public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicationBuilder builder)
{
builder.Services.AddHealthChecks()
// Add a default liveness check to ensure app is responsive
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);

return builder;
}

public static WebApplication MapDefaultEndpoints(this WebApplication app)
{
// Adding health checks endpoints to applications in non-development environments has security implications.
// See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
if (app.Environment.IsDevelopment())
{
// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks("/health");

// Only health checks tagged with the "live" tag must pass for app to be considered alive
app.MapHealthChecks("/alive", new HealthCheckOptions
{
Predicate = r => r.Tags.Contains("live")
});
}

return app;
}
}
22 changes: 22 additions & 0 deletions src/shared/Tasky.ServiceDefaults/Tasky.ServiceDefaults.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireSharedProject>true</IsAspireSharedProject>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.6.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.2" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.0" />
</ItemGroup>

</Project>
Loading

0 comments on commit e72138f

Please sign in to comment.