Skip to content

Commit

Permalink
(#239) Add Aspire
Browse files Browse the repository at this point in the history
  • Loading branch information
phongnguyend committed Jun 21, 2024
1 parent 4d33ee0 commit fb3d27e
Show file tree
Hide file tree
Showing 31 changed files with 361 additions and 48 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/.net-build-microservices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.100


- name: Install Aspire
run: dotnet workload install aspire

- name: Build
run: dotnet build --configuration Release

Expand Down
30 changes: 30 additions & 0 deletions src/Microservices/AspireAppHost/ClassifiedAds.AspireAppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
</PropertyGroup>

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

<ItemGroup>
<ProjectReference Include="..\Gateways.GraphQL\ClassifiedAds.Gateways.GraphQL\ClassifiedAds.Gateways.GraphQL.csproj" />
<ProjectReference Include="..\Gateways.WebAPI\ClassifiedAds.Gateways.WebAPI\ClassifiedAds.Gateways.WebAPI.csproj" />
<ProjectReference Include="..\Services.AuditLog\ClassifiedAds.Services.AuditLog.Api\ClassifiedAds.Services.AuditLog.Api.csproj" />
<ProjectReference Include="..\Services.AuditLog\ClassifiedAds.Services.AuditLog.Grpc\ClassifiedAds.Services.AuditLog.Grpc.csproj" />
<ProjectReference Include="..\Services.Configuration\ClassifiedAds.Services.Configuration.Api\ClassifiedAds.Services.Configuration.Api.csproj" />
<ProjectReference Include="..\Services.Identity\ClassifiedAds.Services.Identity.Api\ClassifiedAds.Services.Identity.Api.csproj" />
<ProjectReference Include="..\Services.Identity\ClassifiedAds.Services.Identity.Grpc\ClassifiedAds.Services.Identity.Grpc.csproj" />
<ProjectReference Include="..\Services.Notification\ClassifiedAds.Services.Notification.Api\ClassifiedAds.Services.Notification.Api.csproj" />
<ProjectReference Include="..\Services.Notification\ClassifiedAds.Services.Notification.Background\ClassifiedAds.Services.Notification.Background.csproj" />
<ProjectReference Include="..\Services.Notification\ClassifiedAds.Services.Notification.Grpc\ClassifiedAds.Services.Notification.Grpc.csproj" />
<ProjectReference Include="..\Services.Product\ClassifiedAds.Services.Product.Api\ClassifiedAds.Services.Product.Api.csproj" />
<ProjectReference Include="..\Services.Storage\ClassifiedAds.Services.Storage.Api\ClassifiedAds.Services.Storage.Api.csproj" />
</ItemGroup>

</Project>
26 changes: 26 additions & 0 deletions src/Microservices/AspireAppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
var builder = DistributedApplication.CreateBuilder(args);

var auditLogApi = builder.AddProject<Projects.ClassifiedAds_Services_AuditLog_Api>("ClassifiedAds-Services-AuditLog-Api");
var auditLogGrpc = builder.AddProject<Projects.ClassifiedAds_Services_AuditLog_Grpc>("ClassifiedAds-Services-AuditLog-Grpc");

var configurationApi = builder.AddProject<Projects.ClassifiedAds_Services_Configuration_Api>("ClassifiedAds-Services-Configuration-Api");

var identityApi = builder.AddProject<Projects.ClassifiedAds_Services_Identity_Api>("ClassifiedAds-Services-Identity-Api");
var identityGrpc = builder.AddProject<Projects.ClassifiedAds_Services_Identity_Grpc>("ClassifiedAds-Services-Identity-Grpc");

var notificationApi = builder.AddProject<Projects.ClassifiedAds_Services_Notification_Api>("ClassifiedAds-Services-Notification-Api");
var notificationGrpc = builder.AddProject<Projects.ClassifiedAds_Services_Notification_Grpc>("ClassifiedAds-Services-Notification-Grpc");
var notificationBackground = builder.AddProject<Projects.ClassifiedAds_Services_Notification_Background>("ClassifiedAds-Services-Notification-Background");

var storageApi = builder.AddProject<Projects.ClassifiedAds_Services_Storage_Api>("ClassifiedAds-Services-Storage-Api");

var productApi = builder.AddProject<Projects.ClassifiedAds_Services_Product_Api>("ClassifiedAds-Services-Product-Api");

var graphQlGateway = builder.AddProject<Projects.ClassifiedAds_Gateways_GraphQL>("ClassifiedAds-Gateways-GraphQL");
var apiGateway = builder.AddProject<Projects.ClassifiedAds_Gateways_WebAPI>("ClassifiedAds-Gateways-WebAPI");


var identityServer = builder
.AddExecutable("ClassifiedAds-IdentityServer", "dotnet", "../../IdentityServer/IdentityServer4/ClassifiedAds.IdentityServer", "run", $"--urls=https://localhost:44367");

builder.Build().Run();
29 changes: 29 additions & 0 deletions src/Microservices/AspireAppHost/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:17063;http://localhost:15113",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21052",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22034"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15113",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19194",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20061"
}
}
}
}
8 changes: 8 additions & 0 deletions src/Microservices/AspireAppHost/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/Microservices/AspireAppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
6 changes: 6 additions & 0 deletions src/Microservices/ClassifiedAds.Microservices.sln
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassifiedAds.Services.Iden
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassifiedAds.Services.Notification", "Services.Notification\ClassifiedAds.Services.Notification\ClassifiedAds.Services.Notification.csproj", "{F09154ED-2C3B-4316-834A-E8207AFDDD6D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassifiedAds.AspireAppHost", "AspireAppHost\ClassifiedAds.AspireAppHost.csproj", "{D1224878-7368-452D-BAE4-0780D737C303}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -147,6 +149,10 @@ Global
{F09154ED-2C3B-4316-834A-E8207AFDDD6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F09154ED-2C3B-4316-834A-E8207AFDDD6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F09154ED-2C3B-4316-834A-E8207AFDDD6D}.Release|Any CPU.Build.0 = Release|Any CPU
{D1224878-7368-452D-BAE4-0780D737C303}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1224878-7368-452D-BAE4-0780D737C303}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1224878-7368-452D-BAE4-0780D737C303}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1224878-7368-452D-BAE4-0780D737C303}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ public static IServiceCollection AddClassifiedAdsOpenTelemetry(this IServiceColl
return services;
}

var resourceBuilder = ResourceBuilder.CreateDefault().AddService(options.ServiceName);

services.AddOpenTelemetry()
.ConfigureResource(configureResource =>
{
configureResource.AddService(
serviceName: options.ServiceName,
serviceVersion: Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "unknown",
serviceInstanceId: Environment.MachineName);
serviceInstanceId: options.ServiceName + "-" + Environment.MachineName);
})
.WithTracing(builder =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ClassifiedAds.Gateways.GraphQL": {
"https": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"applicationUrl": "https://localhost:44311",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"System": "Information",
"Microsoft": "Information"
},
"OpenTelemetry": {
"IsEnabled": true,
"ServiceName": "ClassifiedAds.Gateways.GraphQL",
"Otlp": {
"Endpoint": "https://localhost:21052"
}
}
},
"Monitoring": {
"OpenTelemetry": {
"IsEnabled": true,
"ServiceName": "ClassifiedAds.Gateways.GraphQL",
"Otlp": {
"IsEnabled": true,
"Endpoint": "https://localhost:21052"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ClassifiedAds.Gateways.WebAPI": {
"https": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
"applicationUrl": "https://localhost:44312"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"System": "Information",
"Microsoft": "Information"
},
"OpenTelemetry": {
"IsEnabled": true,
"ServiceName": "ClassifiedAds.Gateways.WebAPI",
"Otlp": {
"Endpoint": "https://localhost:21052"
}
}
},
"Monitoring": {
"OpenTelemetry": {
"IsEnabled": true,
"ServiceName": "ClassifiedAds.Gateways.WebAPI",
"Otlp": {
"IsEnabled": true,
"Endpoint": "https://localhost:21052"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ClassifiedAds.Services.AuditLog": {
"https": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
"applicationUrl": "https://localhost:44378"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"System": "Information",
"Microsoft": "Information"
},
"OpenTelemetry": {
"IsEnabled": true,
"ServiceName": "ClassifiedAds.Services.AuditLog.Api",
"Otlp": {
"Endpoint": "https://localhost:21052"
}
}
},
"Monitoring": {
"OpenTelemetry": {
"IsEnabled": true,
"ServiceName": "ClassifiedAds.Services.AuditLog.Api",
"Otlp": {
"IsEnabled": true,
"Endpoint": "https://localhost:21052"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"profiles": {
"ClassifiedAds.Services.AuditLog.Grpc": {
"https": {
"commandName": "Project",
"launchBrowser": false,
"applicationUrl": "https://localhost:5002",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"System": "Information",
"Microsoft": "Information"
},
"OpenTelemetry": {
"IsEnabled": true,
"ServiceName": "ClassifiedAds.Services.AuditLog.Grpc",
"Otlp": {
"Endpoint": "https://localhost:21052"
}
}
},
"Monitoring": {
"OpenTelemetry": {
"IsEnabled": true,
"ServiceName": "ClassifiedAds.Services.AuditLog.Grpc",
"Otlp": {
"IsEnabled": true,
"Endpoint": "https://localhost:21052"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ClassifiedAds.Services.Configuration.Api": {
"https": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": "true",
"applicationUrl": "https://localhost:5001;http://localhost:5000"
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:44301"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"System": "Information",
"Microsoft": "Information"
},
"OpenTelemetry": {
"IsEnabled": true,
"ServiceName": "ClassifiedAds.Services.Configuration.Api",
"Otlp": {
"Endpoint": "https://localhost:21052"
}
}
},
"Monitoring": {
"OpenTelemetry": {
"IsEnabled": true,
"ServiceName": "ClassifiedAds.Services.Configuration.Api",
"Otlp": {
"IsEnabled": true,
"Endpoint": "https://localhost:21052"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"ClassifiedAds.Services.Identity": {
"https": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
"applicationUrl": "https://localhost:44306"
}
}
}
Loading

0 comments on commit fb3d27e

Please sign in to comment.