Skip to content

Commit 4faf947

Browse files
Init aspire
1 parent b2076b8 commit 4faf947

File tree

24 files changed

+337
-155
lines changed

24 files changed

+337
-155
lines changed

Directory.Packages.props

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,14 @@
6464
<PackageVersion Include="MSTest.TestFramework" Version="3.6.4" />
6565
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
6666
<PackageVersion Include="NUnit" Version="4.2.2" />
67+
<PackageVersion Include="Aspire.Hosting.AppHost" Version="9.0.0" />
68+
<PackageVersion Include="Aspire.Hosting.MongoDB" Version="9.0.0" />
69+
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="9.0.0" />
70+
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="9.0.0" />
71+
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
72+
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
73+
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
74+
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
75+
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.9.0" />
6776
</ItemGroup>
6877
</Project>

GrandNode.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grand.Module.Api", "src\Mod
137137
EndProject
138138
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Grand.Module.ScheduledTasks", "src\Modules\Grand.Module.ScheduledTasks\Grand.Module.ScheduledTasks.csproj", "{136F1E35-8B20-465C-8D42-30A5A0D0DA1F}"
139139
EndProject
140+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.AppHost", "src\Aspire\Aspire.AppHost\Aspire.AppHost.csproj", "{FFA85947-690E-496B-B21E-DB1800F0DCA9}"
141+
EndProject
142+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.ServiceDefaults", "src\Aspire\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj", "{591950E4-6377-4ECA-A386-8BD3FFE302F1}"
143+
EndProject
140144
Global
141145
GlobalSection(SolutionConfigurationPlatforms) = preSolution
142146
Debug|Any CPU = Debug|Any CPU
@@ -363,6 +367,14 @@ Global
363367
{136F1E35-8B20-465C-8D42-30A5A0D0DA1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
364368
{136F1E35-8B20-465C-8D42-30A5A0D0DA1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
365369
{136F1E35-8B20-465C-8D42-30A5A0D0DA1F}.Release|Any CPU.Build.0 = Release|Any CPU
370+
{FFA85947-690E-496B-B21E-DB1800F0DCA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
371+
{FFA85947-690E-496B-B21E-DB1800F0DCA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
372+
{FFA85947-690E-496B-B21E-DB1800F0DCA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
373+
{FFA85947-690E-496B-B21E-DB1800F0DCA9}.Release|Any CPU.Build.0 = Release|Any CPU
374+
{591950E4-6377-4ECA-A386-8BD3FFE302F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
375+
{591950E4-6377-4ECA-A386-8BD3FFE302F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
376+
{591950E4-6377-4ECA-A386-8BD3FFE302F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
377+
{591950E4-6377-4ECA-A386-8BD3FFE302F1}.Release|Any CPU.Build.0 = Release|Any CPU
366378
EndGlobalSection
367379
GlobalSection(SolutionProperties) = preSolution
368380
HideSolutionNode = FALSE
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0" />
4+
5+
<PropertyGroup>
6+
<OutputType>Exe</OutputType>
7+
<TargetFramework>net9.0</TargetFramework>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
<Nullable>enable</Nullable>
10+
<IsAspireHost>true</IsAspireHost>
11+
<UserSecretsId>bdc1e5b4-4475-44fc-851c-dd576ac2c123</UserSecretsId>
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<PackageReference Include="Aspire.Hosting.AppHost" />
16+
<PackageReference Include="Aspire.Hosting.MongoDB" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<ProjectReference Include="..\..\Web\Grand.Web\Grand.Web.csproj" />
21+
</ItemGroup>
22+
23+
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
var builder = DistributedApplication.CreateBuilder(args);
3+
4+
5+
var mongo = builder.AddMongoDB("mongo")
6+
.WithLifetime(ContainerLifetime.Persistent);
7+
8+
var mongodb = mongo.AddDatabase("Mongodb");
9+
10+
builder
11+
.AddProject<Projects.Grand_Web>("grand-web")
12+
.WithHttpEndpoint(80)
13+
.WithEnvironment("", "")
14+
.WithReference(mongodb)
15+
.WaitFor(mongodb);
16+
17+
builder.Build().Run();
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"https": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": true,
8+
"applicationUrl": "https://localhost:17196;http://localhost:15129",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development",
11+
"DOTNET_ENVIRONMENT": "Development",
12+
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21225",
13+
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22257",
14+
"ASPIRE_ALLOW_UNSECURED_TRANSPORT": "true"
15+
}
16+
},
17+
"http": {
18+
"commandName": "Project",
19+
"dotnetRunMessages": true,
20+
"launchBrowser": true,
21+
"applicationUrl": "http://localhost:15129",
22+
"environmentVariables": {
23+
"ASPNETCORE_ENVIRONMENT": "Development",
24+
"DOTNET_ENVIRONMENT": "Development",
25+
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19032",
26+
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20163",
27+
"ASPIRE_ALLOW_UNSECURED_TRANSPORT": "true"
28+
29+
}
30+
}
31+
}
32+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning",
6+
"Aspire.Hosting.Dcp": "Warning"
7+
}
8+
}
9+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<IsAspireSharedProject>true</IsAspireSharedProject>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
12+
13+
<PackageReference Include="Microsoft.Extensions.Http.Resilience" />
14+
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" />
15+
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" />
16+
<PackageReference Include="OpenTelemetry.Extensions.Hosting" />
17+
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
18+
<PackageReference Include="OpenTelemetry.Instrumentation.Http" />
19+
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
3+
using Microsoft.Extensions.DependencyInjection;
4+
using Microsoft.Extensions.Diagnostics.HealthChecks;
5+
using Microsoft.Extensions.Logging;
6+
using Microsoft.Extensions.ServiceDiscovery;
7+
using OpenTelemetry;
8+
using OpenTelemetry.Metrics;
9+
using OpenTelemetry.Trace;
10+
11+
namespace Microsoft.Extensions.Hosting;
12+
13+
// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
14+
// This project should be referenced by each service project in your solution.
15+
// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
16+
public static class Extensions
17+
{
18+
public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
19+
{
20+
builder.ConfigureOpenTelemetry();
21+
22+
builder.Services.AddServiceDiscovery();
23+
24+
builder.Services.ConfigureHttpClientDefaults(http =>
25+
{
26+
// Turn on resilience by default
27+
http.AddStandardResilienceHandler();
28+
29+
// Turn on service discovery by default
30+
http.AddServiceDiscovery();
31+
});
32+
33+
// Uncomment the following to restrict the allowed schemes for service discovery.
34+
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
35+
// {
36+
// options.AllowedSchemes = ["https"];
37+
// });
38+
39+
return builder;
40+
}
41+
42+
public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
43+
{
44+
builder.Logging.AddOpenTelemetry(logging =>
45+
{
46+
logging.IncludeFormattedMessage = true;
47+
logging.IncludeScopes = true;
48+
});
49+
50+
builder.Services.AddOpenTelemetry()
51+
.WithMetrics(metrics =>
52+
{
53+
metrics.AddAspNetCoreInstrumentation()
54+
.AddHttpClientInstrumentation()
55+
.AddRuntimeInstrumentation();
56+
})
57+
.WithTracing(tracing =>
58+
{
59+
tracing.AddSource(builder.Environment.ApplicationName)
60+
.AddAspNetCoreInstrumentation()
61+
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
62+
//.AddGrpcClientInstrumentation()
63+
.AddHttpClientInstrumentation();
64+
});
65+
66+
builder.AddOpenTelemetryExporters();
67+
68+
return builder;
69+
}
70+
71+
private static TBuilder AddOpenTelemetryExporters<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
72+
{
73+
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);
74+
75+
if (useOtlpExporter)
76+
{
77+
builder.Services.AddOpenTelemetry().UseOtlpExporter();
78+
}
79+
80+
// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
81+
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
82+
//{
83+
// builder.Services.AddOpenTelemetry()
84+
// .UseAzureMonitor();
85+
//}
86+
87+
return builder;
88+
}
89+
}

src/Core/Grand.Infrastructure/Configuration/DatabaseConfig.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,4 @@ public class DatabaseConfig
1616
/// Gets or sets a value indicating whether use LiteDB database (only for installation process)
1717
/// </summary>
1818
public string LiteDbConnectionString { get; set; }
19-
20-
/// <summary>
21-
/// Gets or sets a value indicating whether use connection string for database (only for installed databases)
22-
/// </summary>
23-
public string ConnectionString { get; set; }
24-
25-
public int DbProvider { get; set; }
2619
}

0 commit comments

Comments
 (0)