Skip to content

Commit

Permalink
Update to preview.6 (#29)
Browse files Browse the repository at this point in the history
* Building successfully on preview.6

* Fix launchSettings files

* Actually fix launchSettings files

* Fix KeyCloak

* Update build scripts to install Aspire workload

* Add an integration test

* Update WebAppTests.cs

* Update WebAppTests.cs

* Add test infrastructure

* Make KeyCloak resource auto-manage client secret

* Update WebAppTests.cs

* Update WebAppTests.cs

* Comment out RedisCommander & PgAdmin for now

* Increase test timeout

* Update action versions

* Fix ILogger output for tests

* Disable HTTPS in CI

* Try to re-enable HTTPS

* Update ci.yml

* Re-enable Redis commander and pgAdmin

* More HTTPS, Keycloak tweak & update ServiceDefaults

* Whoops, too much HTTPS

* Update launchSettings.json in labs

* Update KeycloakResource in labs

* Update ci.yml
  • Loading branch information
DamianEdwards authored Apr 27, 2024
1 parent caf3ec8 commit 37fac08
Show file tree
Hide file tree
Showing 192 changed files with 2,921 additions and 1,466 deletions.
31 changes: 28 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,37 @@ jobs:
DOTNET_MULTILEVEL_LOOKUP: false
DOTNET_INSTALL_DIR: ${{ matrix.os == 'ubuntu-latest' && '' || 'dotnet' }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
global-json-file: ${{ matrix.os == 'ubuntu-latest' && './global.json' || '.\global.json' }}

- name: Build
run: ${{ matrix.os == 'ubuntu-latest' && './build.sh' || '.\build.cmd' }}
run: ${{ matrix.os == 'ubuntu-latest' && './build.sh' || '.\build.cmd' }}

- name: Install .NET HTTPS Development Certificate
if: matrix.os == 'ubuntu-latest'
run: |
dotnet tool update -g linux-dev-certs
dotnet linux-dev-certs install
- name: Test
id: test
# Can't run Docker on Windows agents yet
if: matrix.os == 'ubuntu-latest'
# Note that the space after the last double dash (--) is intentional
run: >
dotnet test ./eShop.sln
--logger console --logger trx --logger html --logger GitHubActions
--results-directory ./TestResults --blame
--
RunConfiguration.CollectSourceInformation=true
- name: Publish Test Results
if: (success() || steps.test.conclusion == 'failure') && matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: TestResults_${{ matrix.os }}
path: ./TestResults
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ In this workshop, you'll learn by building out features of the [eShop Reference

### Using Windows and Visual Studio

If you're on Windows and using Visual Studio, you must use [Visual Studio 2022 Preview](https://visualstudio.com/preview) (version 17.9.0 Preview 5.0 or later). The preview version of Visual Studio 2022 is safe to install side-by-side with the release version. We recommend using Visual Studio 2022 Preview if you're on Windows as it includes support for working with .NET Aspire projects.
If you're on Windows and using Visual Studio, you must use [Visual Studio 2022 Preview](https://visualstudio.com/preview) (version 17.10.0 Preview 5.0 or later). The preview version of Visual Studio 2022 is safe to install side-by-side with the release version. We recommend using Visual Studio 2022 Preview if you're on Windows as it includes support for working with .NET Aspire projects.

> Note: When installing Visual Studio you only need to install the `ASP.NET and web development` workload.
If you're in an instructor-led workshop session and have issues downloading the installers we may have USB sticks with offline installers for you to use.

### Using macOS, Linux, or Windows but not using Visual Studio

If you're using macOs or Linux, or on Windows but don't want to use Visual Studio, you must [download](https://www.microsoft.com/net/download) and install the .NET SDK (version 8.0.101 or newer). You can use the editor or IDE of your choice but note that some operations might be more difficult due to lack of support for .NET Aspire at this time.
If you're using macOs or Linux, or on Windows but don't want to use Visual Studio, you must [download](https://www.microsoft.com/net/download) and install the .NET SDK (version 8.0.100 or newer). You can use the editor or IDE of your choice but note that some operations might be more difficult due to lack of support for .NET Aspire at this time.

### Updating and installing the .NET SDK workload for Aspire

After installing Visual Studio Preview or the required .NET SDK, you will need to update and install the .NET SDK workload for Aspire. This workshop is using an as yet unreleased preview of .NET Aspire (preview.3) which requires [special steps to install](https://github.com/dotnet/aspire/blob/dc8fa33195ef1f66b920206766b9224c4c3f19bd/docs/using-latest-daily.md#optional-using-scripts-to-install-the-latest-net-aspire-build-from-release-branches). For your convenience, scripts are provided in this repository to make this process easy:
After installing Visual Studio Preview or the required .NET SDK, you will need to update and install the .NET SDK workload for Aspire. This workshop is using the latest preview of .NET Aspire (preview.6). For your convenience, scripts are provided in this repository to make this process easy:

1. Clone [this repo](https://github.com/dotnet-presentations/eshop-app-workshop) to your machine.
1. In your terminal, navigate to the repo root and run the command `dotnet --version` to verify you are using version 8.0.101 or later of the .NET SDK:
1. In your terminal, navigate to the repo root and run the command `dotnet --version` to verify you are using version 8.0.100 or later of the .NET SDK:

```shell
dotnet --version
Expand All @@ -43,15 +43,14 @@ After installing Visual Studio Preview or the required .NET SDK, you will need t
build.sh
```

1. This script will download and install the latest build of the preview.3 version of the Aspire workload, followed by building all solutions in this repo.
1. This script will download and install the latest build of the preview.6 version of the Aspire workload, followed by building all solutions in this repo.
1. If your machine is successfully configured, you should see a message indicating the build succeeded:

```shell
Build succeeded.
0 Warning(s)
0 Error(s)
```
1. For troubleshooting steps regarding installing and updating the Aspire workload, see the [documentation here](https://github.com/dotnet/aspire/blob/dc8fa33195ef1f66b920206766b9224c4c3f19bd/docs/using-latest-daily.md#troubleshooting).

## Labs

Expand Down
2 changes: 2 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@ECHO OFF

dotnet workload install aspire

dotnet build .\build\Build.proj
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

dotnet workload install aspire

dotnet build ./build/Build.proj
8 changes: 7 additions & 1 deletion eShop.sln
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Catalog.Data", "src\Catalog
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Catalog.Data.Manager", "src\Catalog.Data.Manager\Catalog.Data.Manager.csproj", "{E1AAD2C8-97A7-404E-9DF7-89A719101631}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ordering.Data", "src\Ordering.Data\Ordering.Data.csproj", "{D68FAD25-C09D-434C-A7AE-8F78DB2D923D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ordering.Data", "src\Ordering.Data\Ordering.Data.csproj", "{D68FAD25-C09D-434C-A7AE-8F78DB2D923D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ordering.Data.Manager", "src\Ordering.Data.Manager\Ordering.Data.Manager.csproj", "{4FCA8863-B3C7-47D6-B031-37A0384B40AA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationTests", "src\IntegrationTests\IntegrationTests.csproj", "{78A319E7-76E6-4813-9C36-CB90B406A91D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -82,6 +84,10 @@ Global
{4FCA8863-B3C7-47D6-B031-37A0384B40AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4FCA8863-B3C7-47D6-B031-37A0384B40AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4FCA8863-B3C7-47D6-B031-37A0384B40AA}.Release|Any CPU.Build.0 = Release|Any CPU
{78A319E7-76E6-4813-9C36-CB90B406A91D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78A319E7-76E6-4813-9C36-CB90B406A91D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78A319E7-76E6-4813-9C36-CB90B406A91D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78A319E7-76E6-4813-9C36-CB90B406A91D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.101",
"version": "8.0.100",
"rollForward": "latestFeature",
"allowPrerelease": true
}
Expand Down
Empty file removed kill
Empty file.
10 changes: 10 additions & 0 deletions labs/1-Create-Catalog-API/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ Containers are extremely useful for hosting service dependencies, but rather tha

### Configuring PostgreSQL and pgAdmin

1. Install the `Aspire.Hosting.PostgreSQL` package in the `eShop.AppHost` project:

```shell
dotnet add package Aspire.Hosting.Redis
```

```xml
<PackageReference Include="Aspire.Hosting.PostgreSQL" Version="8.0.0-preview.6.24214.1" />
```

1. Use the methods on the `builder` variable to create a PostgreSQL instance called `postgres` with pgAdmin enabled, and a database called `CatalogDB`. Ensure that the `catalog-db-mgr` project resource is configured with a reference to the `catalogDb`:

```csharp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:63531",
"sslPort": 0
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5180",
"applicationUrl": "http://localhost:5222/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7129/;http://localhost:5222/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0-preview.3.24105.21" />
<PackageReference Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0-preview.6.24214.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0-preview.3.24105.21" />
<PackageReference Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0-preview.6.24214.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17219;http://localhost:15178",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21023",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22616"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15157",
"applicationUrl": "http://localhost:15178",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16185"
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19076",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20023"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting" Version="8.0.0-preview.3.24105.21" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="8.0.0-preview.6.24214.1" />
<PackageReference Include="Aspire.Hosting.PostgreSQL" Version="8.0.0-preview.6.24214.1" />
</ItemGroup>

<ItemGroup>
Expand Down
61 changes: 21 additions & 40 deletions labs/1-Create-Catalog-API/end/eShop.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using OpenTelemetry.Logs;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;

Expand All @@ -25,34 +25,29 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
http.AddStandardResilienceHandler();

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

return builder;
}

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

builder.Services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics.AddRuntimeInstrumentation()
.AddBuiltInMeters();
metrics.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation();
})
.WithTracing(tracing =>
{
if (builder.Environment.IsDevelopment())
{
// We want to view all traces in development
tracing.SetSampler(new AlwaysOnSampler());
}

tracing.AddAspNetCoreInstrumentation()
.AddGrpcClientInstrumentation()
.AddHttpClientInstrumentation();
Expand All @@ -69,19 +64,9 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli

if (useOtlpExporter)
{
builder.Services.Configure<OpenTelemetryLoggerOptions>(logging => logging.AddOtlpExporter());
builder.Services.ConfigureOpenTelemetryMeterProvider(metrics => metrics.AddOtlpExporter());
builder.Services.ConfigureOpenTelemetryTracerProvider(tracing => tracing.AddOtlpExporter());
builder.Services.AddOpenTelemetry().UseOtlpExporter();
}

// Uncomment the following lines to enable the Prometheus exporter (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package)
// builder.Services.AddOpenTelemetry()
// .WithMetrics(metrics => metrics.AddPrometheusExporter());

// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
// builder.Services.AddOpenTelemetry()
// .UseAzureMonitor();

return builder;
}

Expand All @@ -96,24 +81,20 @@ public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicati

public static WebApplication MapDefaultEndpoints(this WebApplication app)
{
// Uncomment the following line to enable the Prometheus endpoint (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package)
// app.MapPrometheusScrapingEndpoint();

// 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
// 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())
{
Predicate = r => r.Tags.Contains("live")
});
// 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;
}

private static MeterProviderBuilder AddBuiltInMeters(this MeterProviderBuilder meterProviderBuilder) =>
meterProviderBuilder.AddMeter(
"Microsoft.AspNetCore.Hosting",
"Microsoft.AspNetCore.Server.Kestrel",
"System.Net.Http");
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.1.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.0-preview.3.24105.21" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.6.0-beta.3" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.7.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.0-preview.6.24214.1" />
<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.GrpcNetClient" Version="1.8.0-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0-preview.3.24105.21" />
<PackageReference Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0-preview.6.24214.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0-preview.3.24105.21" />
<PackageReference Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0-preview.6.24214.1" />
</ItemGroup>

</Project>
Loading

0 comments on commit 37fac08

Please sign in to comment.