Skip to content

Commit a619001

Browse files
updated with health checks
1 parent c32f782 commit a619001

File tree

9 files changed

+36
-9
lines changed

9 files changed

+36
-9
lines changed

CarvedRock.Api/CarvedRock.Api.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<PackageReference Include="Hellang.Middleware.ProblemDetails" Version="6.3.0" />
1111
<PackageReference Include="IdentityModel" Version="6.0.0" />
1212
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
13+
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
1314
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
1415

1516
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="6.0.1" />

CarvedRock.Api/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
builder.Host.UseSerilog((context, loggerConfig) => {
2222
loggerConfig
23+
.ReadFrom.Configuration(context.Configuration)
2324
.WriteTo.Console()
2425
.Enrich.WithExceptionDetails()
2526
.WriteTo.Seq("http://localhost:5341");
@@ -90,7 +91,7 @@
9091
});
9192
}
9293
app.MapFallback(() => Results.Redirect("/swagger"));
93-
app.UseHttpsRedirection();
94+
//app.UseHttpsRedirection();
9495
app.UseAuthentication();
9596
app.UseMiddleware<UserScopeMiddleware>();
9697
app.UseAuthorization();

CarvedRock.Api/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"commandName": "Project",
1414
"dotnetRunMessages": true,
1515
"launchBrowser": true,
16-
"applicationUrl": "https://localhost:7213;http://localhost:5022",
16+
"applicationUrl": "https://localhost:7213;http://localhost:5022",
1717
"environmentVariables": {
1818
"ASPNETCORE_ENVIRONMENT": "Development"
1919
}

CarvedRock.Api/appsettings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
"ApplicationInsights": {
33
"ConnectionString": "InstrumentationKey=ec748731-430b-4f07-bd28-951e421fa034;IngestionEndpoint=https://westus2-2.in.applicationinsights.azure.com/"
44
},
5+
"Serilog": {
6+
"MinimumLevel": {
7+
"Default": "Information",
8+
"Override": {
9+
"Microsoft.AspNetCore": "Warning",
10+
"CarvedRock": "Debug",
11+
"System": "Warning",
12+
"Microsoft.Hosting.Diagnostics": "Warning"
13+
}
14+
}
15+
},
516
"Logging": {
617
"LogLevel": {
718
"Default": "Information",

CarvedRock.WebApp/CarvedRock.WebApp.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" />
2020

2121
<!-- Serilog / Seq -->
22-
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
22+
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
23+
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
2324
<PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1" />
2425
<PackageReference Include="Serilog.Exceptions" Version="8.0.0" />
2526

CarvedRock.WebApp/Pages/Listing.cshtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public ListingModel(HttpClient apiClient, ILogger<ListingModel> logger,
1717
{
1818
_logger = logger;
1919
_apiClient = apiClient;
20-
_apiClient.BaseAddress = new Uri("https://localhost:7213/");
20+
_apiClient.BaseAddress = new Uri("https://localhost:7213");
2121
_httpCtx = httpContextAccessor.HttpContext;
2222
}
2323

CarvedRock.WebApp/Program.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
builder.Host.UseSerilog((context, loggerConfig) => {
1616
loggerConfig
17+
.ReadFrom.Configuration(context.Configuration)
1718
.WriteTo.Console()
1819
.Enrich.WithExceptionDetails()
1920
.WriteTo.Seq("http://localhost:5341");
@@ -26,7 +27,7 @@
2627
builder.Services.AddAuthentication(options =>
2728
{
2829
options.DefaultScheme = "Cookies";
29-
options.DefaultChallengeScheme = "oidc";
30+
options.DefaultChallengeScheme = "oidc";
3031
})
3132
.AddCookie("Cookies")
3233
.AddOpenIdConnect("oidc", options =>
@@ -44,7 +45,7 @@
4445
options.TokenValidationParameters = new TokenValidationParameters
4546
{
4647
NameClaimType = "email"
47-
};
48+
};
4849
options.SaveTokens = true;
4950
});
5051
builder.Services.AddHttpContextAccessor();
@@ -57,10 +58,11 @@
5758
var app = builder.Build();
5859

5960
app.UseExceptionHandler("/Error");
61+
6062
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
61-
app.UseHsts();
63+
//app.UseHsts();
64+
//app.UseHttpsRedirection();
6265

63-
app.UseHttpsRedirection();
6466
app.UseStaticFiles();
6567

6668
app.UseRouting();

CarvedRock.WebApp/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"commandName": "Project",
1313
"dotnetRunMessages": true,
1414
"launchBrowser": true,
15-
"applicationUrl": "https://localhost:7224;http://localhost:5224",
15+
"applicationUrl": "https://localhost:7224;http://localhost:5224",
1616
"environmentVariables": {
1717
"ASPNETCORE_ENVIRONMENT": "Development"
1818
}

CarvedRock.WebApp/appsettings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
"ApplicationInsights": {
33
"ConnectionString": "InstrumentationKey=ec748731-430b-4f07-bd28-951e421fa034;IngestionEndpoint=https://westus2-2.in.applicationinsights.azure.com/"
44
},
5+
"Serilog": {
6+
"MinimumLevel": {
7+
"Default": "Information",
8+
"Override": {
9+
"Microsoft.AspNetCore": "Warning",
10+
"CarvedRock": "Debug",
11+
"System": "Warning",
12+
"Microsoft.Hosting.Diagnostics": "Warning"
13+
}
14+
}
15+
},
516
"Logging": {
617
"LogLevel": {
718
"Default": "Information",

0 commit comments

Comments
 (0)