From fef46389812a8f5b6625ec2978b9e7b5fc07214b Mon Sep 17 00:00:00 2001 From: David Pine Date: Thu, 9 May 2024 07:56:38 -0500 Subject: [PATCH 1/2] Address all issues in #720 --- docs/fundamentals/components-overview.md | 6 +-- docs/fundamentals/dashboard/standalone.md | 12 ++--- .../build-your-first-aspire-app.md | 2 +- .../AspireSample.ApiService.csproj | 1 - .../AspireSample.ApiService/Program.cs | 4 +- .../Properties/launchSettings.json | 6 +-- .../AspireSample.AppHost.csproj | 3 +- .../AspireSample.AppHost/Program.cs | 5 ++- .../Properties/launchSettings.json | 16 ++++--- .../AspireSample.AppHost/appsettings.json | 3 +- .../AspireSample.ServiceDefaults.csproj | 4 +- .../Extensions.cs | 20 ++------- .../AspireSample.Web/AspireSample.Web.csproj | 3 +- .../Components/Layout/MainLayout.razor | 2 +- .../Components/Layout/NavMenu.razor | 2 +- .../AspireSample/AspireSample.Web/Program.cs | 17 ++++--- .../Properties/launchSettings.json | 6 +-- .../AspireSample.Web/WeatherApiClient.cs | 19 +++++++- .../AspireSample.Web/wwwroot/app.css | 4 +- .../quickstart/AspireSample/AspireSample.sln | 45 +++++++++---------- docs/includes/aspire-prereqs.md | 4 +- 21 files changed, 98 insertions(+), 86 deletions(-) diff --git a/docs/fundamentals/components-overview.md b/docs/fundamentals/components-overview.md index b9239e1559..a2a55de77f 100644 --- a/docs/fundamentals/components-overview.md +++ b/docs/fundamentals/components-overview.md @@ -1,7 +1,7 @@ --- title: .NET Aspire components overview description: Explore the fundamental concepts of .NET Aspire components and learn how to integrate them into your apps. -ms.date: 12/20/2023 +ms.date: 05/09/2024 ms.topic: conceptual --- @@ -42,7 +42,7 @@ For more information on working with .NET Aspire components in Visual Studio, se ## Explore a sample component workflow -.NET Aspire components streamline the process of consuming popular services and platforms. For example, consider the **.NET Aspire Application** template. With this template, you get the [AppHost](app-host-overview.md) and [ServiceDefaults](service-defaults.md) projects. Imagine that you have a need for a worker service to perform some database processing. You could use the [.NET Aspire PostgreSQL component](../database/postgresql-component.md) to connect to and utilize a PostgreSQL database. The database could be hosted on-prem or in a cloud service such as Azure, AWS, or GCP. The following steps demonstrate how to integrate this component into your app: +.NET Aspire components streamline the process of consuming popular services and platforms. For example, consider the **.NET Aspire Application** template. With this template, you get the [AppHost](app-host-overview.md) and [ServiceDefaults](service-defaults.md) projects. Imagine that you have a need for a worker service to perform some database processing. You could use the [.NET Aspire PostgreSQL component](../database/postgresql-component.md) to connect to and utilize a PostgreSQL database. The database could be hosted on-prem or in a cloud service such as Azure, AWS, or GCP. The following steps demonstrate how to integrate this component into your app: 1. In the component consuming (worker service) project, install the [Aspire.Npgsql](https://www.nuget.org/packages/Aspire.Npgsql) NuGet package. @@ -73,7 +73,7 @@ For more information on working with .NET Aspire components in Visual Studio, se 1. In your app host project (the project with the _*.AppHost_ suffix), add a reference to the worker service project. If you're using Visual Studio, you can use the [**Add .NET Aspire Orchestrator Support**](setup-tooling.md#add-orchestration-projects) project context menu item to add the reference automatically. The following code snippet shows the project reference of the _AspireApp.AppHost.csproj_: - :::code language="xml" source="snippets/components/AspireApp/AspireApp.AppHost/AspireApp.AppHost.csproj" highlight="16"::: + :::code language="xml" source="snippets/components/AspireApp/AspireApp.AppHost/AspireApp.AppHost.csproj" highlight="17"::: After the worker service is referenced by the orchestrator project, the worker service project has its _Program.cs_ file updated to call the `AddServiceDefaults` method. For more information on service defaults, see [Service defaults](service-defaults.md). diff --git a/docs/fundamentals/dashboard/standalone.md b/docs/fundamentals/dashboard/standalone.md index 907fa53154..b714128c91 100644 --- a/docs/fundamentals/dashboard/standalone.md +++ b/docs/fundamentals/dashboard/standalone.md @@ -1,7 +1,7 @@ --- title: Standalone .NET Aspire dashboard description: How to use the .NET Aspire dashboard standalone. -ms.date: 04/30/2024 +ms.date: 05/09/2024 ms.topic: reference --- @@ -9,7 +9,7 @@ ms.topic: reference The [.NET Aspire dashboard](overview.md) provides a great UI for viewing telemetry. The dashboard: -- Ships as a Docker image that can be used with any OpenTelemetry enabled app. +- Ships as a container image that can be used with any OpenTelemetry enabled app. - Can be used standalone, without the rest of .NET Aspire. :::image type="content" source="media/explore/trace.png" lightbox="media/explore/trace.png" alt-text="A screenshot of the .NET Aspire dashboard Trace details page."::: @@ -20,12 +20,12 @@ The dashboard is started using the Docker command line. ```bash docker run --rm -it -p 18888:18888 -p 4317:18889 -d --name aspire-dashboard \ - mcr.microsoft.com/dotnet/nightly/aspire-dashboard:8.0.0-preview.6 + mcr.microsoft.com/dotnet/nightly/aspire-dashboard:8.0.0-preview.7 ``` The preceding Docker command: -- Starts a container from the `mcr.microsoft.com/dotnet/nightly/aspire-dashboard:8.0.0-preview.6` image. +- Starts a container from the `mcr.microsoft.com/dotnet/nightly/aspire-dashboard:8.0.0-preview.7` image. - The container has two ports: - Port `4317` receives OpenTelemetry data from apps. Apps send data using [OpenTelemetry Protocol (OTLP)](https://opentelemetry.io/docs/specs/otlp/). - Port `18888` has the dashboard UI. Navigate to `http://localhost:18888` in the browser to view the dashboard. @@ -48,7 +48,7 @@ The dashboard offers a UI for viewing telemetry. Refer to the documentation to e - [Traces page](explore.md#traces-page) - [Metrics page](explore.md#metrics-page) -Although there is no restriction on where the dashboard is run, the dashboard is designed as a development and short-term diagnosic tool. The dashboard persists telemetry in-memory which creates some limitations: +Although there is no restriction on where the dashboard is run, the dashboard is designed as a development and short-term diagnostic tool. The dashboard persists telemetry in-memory which creates some limitations: - Telemetry is automatically removed if [telemetry limits](configuration.md#telemetry-limits) are exceeded. - No telemetry is persisted when the dashboard is restarted. @@ -67,7 +67,7 @@ Apps collect and send telemetry using [their language's OpenTelemetry SDK](https Important OpenTelemetry SDK options to configure: -- OTLP endpoint, which should match the dashboard's configuration, e.g., `http://localhost:4317`. +- OTLP endpoint, which should match the dashboard's configuration, for example, `http://localhost:4317`. - OTLP protocol, with the dashboard currently supporting only the [OTLP/gRPC protocol](https://opentelemetry.io/docs/specs/otlp/#otlpgrpc). Configure applications to use the `grpc` protocol. To configure applications: diff --git a/docs/get-started/build-your-first-aspire-app.md b/docs/get-started/build-your-first-aspire-app.md index 43c6d70c81..847de8c4a7 100644 --- a/docs/get-started/build-your-first-aspire-app.md +++ b/docs/get-started/build-your-first-aspire-app.md @@ -1,7 +1,7 @@ --- title: Build your first .NET Aspire app description: Learn how to build your first .NET Aspire app using the .NET Aspire Started Application template. -ms.date: 12/07/2023 +ms.date: 05/09/2024 ms.topic: quickstart --- diff --git a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ApiService/AspireSample.ApiService.csproj b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ApiService/AspireSample.ApiService.csproj index 74c9840473..884b602434 100644 --- a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ApiService/AspireSample.ApiService.csproj +++ b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ApiService/AspireSample.ApiService.csproj @@ -1,7 +1,6 @@ - Exe net8.0 enable enable diff --git a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ApiService/Program.cs b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ApiService/Program.cs index 868de0085c..a93ae74197 100644 --- a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ApiService/Program.cs +++ b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ApiService/Program.cs @@ -1,4 +1,4 @@ -var builder = WebApplication.CreateBuilder(args); +var builder = WebApplication.CreateBuilder(args); // Add service defaults & Aspire components. builder.AddServiceDefaults(); @@ -18,7 +18,7 @@ app.MapGet("/weatherforecast", () => { - var forecast = Enumerable.Range(1, 5).Select(index => + var forecast = Enumerable.Range(1, 5).Select(index => new WeatherForecast ( DateOnly.FromDateTime(DateTime.Now.AddDays(index)), diff --git a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ApiService/Properties/launchSettings.json b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ApiService/Properties/launchSettings.json index 1f9864ddf7..44dc06a6b7 100644 --- a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ApiService/Properties/launchSettings.json +++ b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ApiService/Properties/launchSettings.json @@ -1,12 +1,12 @@ { - "$schema": "http://json.schemastore.org/launchsettings.json", + "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { "http": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "weatherforecast", - "applicationUrl": "http://localhost:5499", + "applicationUrl": "http://localhost:5593", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -16,7 +16,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "weatherforecast", - "applicationUrl": "https://localhost:7453;http://localhost:5499", + "applicationUrl": "https://localhost:7352;http://localhost:5593", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/AspireSample.AppHost.csproj b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/AspireSample.AppHost.csproj index e793219d75..096dbcf111 100644 --- a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/AspireSample.AppHost.csproj +++ b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/AspireSample.AppHost.csproj @@ -1,4 +1,4 @@ - + Exe @@ -6,6 +6,7 @@ enable enable true + 1b1a6997-c2dd-47d0-b3fa-46811f182483 diff --git a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/Program.cs b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/Program.cs index 6497f8040d..7da85487da 100644 --- a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/Program.cs +++ b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/Program.cs @@ -2,10 +2,11 @@ var cache = builder.AddRedis("cache"); -var apiservice = builder.AddProject("apiservice"); +var apiService = builder.AddProject("apiservice"); builder.AddProject("webfrontend") + .WithExternalHttpEndpoints() .WithReference(cache) - .WithReference(apiservice); + .WithReference(apiService); builder.Build().Run(); diff --git a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/Properties/launchSettings.json b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/Properties/launchSettings.json index 233be48cb0..97b97e7a45 100644 --- a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/Properties/launchSettings.json +++ b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/Properties/launchSettings.json @@ -1,26 +1,28 @@ { - "$schema": "http://json.schemastore.org/launchsettings.json", + "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { - "http": { + "https": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "http://localhost:15031", + "applicationUrl": "https://localhost:17187;http://localhost:15293", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", "DOTNET_ENVIRONMENT": "Development", - "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16048" + "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21171", + "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22170" } }, - "https": { + "http": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "https://localhost:17099;http://localhost:15031", + "applicationUrl": "http://localhost:15293", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", "DOTNET_ENVIRONMENT": "Development", - "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:18068" + "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19179", + "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20127" } } } diff --git a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/appsettings.json b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/appsettings.json index 0c208ae918..31c092aa45 100644 --- a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/appsettings.json +++ b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.AppHost/appsettings.json @@ -2,7 +2,8 @@ "Logging": { "LogLevel": { "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Microsoft.AspNetCore": "Warning", + "Aspire.Hosting.Dcp": "Warning" } } } diff --git a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ServiceDefaults/AspireSample.ServiceDefaults.csproj b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ServiceDefaults/AspireSample.ServiceDefaults.csproj index 85621e6959..f48299bb58 100644 --- a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ServiceDefaults/AspireSample.ServiceDefaults.csproj +++ b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ServiceDefaults/AspireSample.ServiceDefaults.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -10,7 +10,7 @@ - + diff --git a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ServiceDefaults/Extensions.cs b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ServiceDefaults/Extensions.cs index f00dc4ecea..877f870b74 100644 --- a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ServiceDefaults/Extensions.cs +++ b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.ServiceDefaults/Extensions.cs @@ -1,9 +1,9 @@ -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Logging; -using OpenTelemetry.Logs; +using OpenTelemetry; using OpenTelemetry.Metrics; using OpenTelemetry.Trace; @@ -28,12 +28,6 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu http.AddServiceDiscovery(); }); - // Uncomment the following to restrict the allowed schemes for service discovery. - // builder.Services.Configure(options => - // { - // options.AllowedSchemes = ["https"]; - // }); - return builder; } @@ -54,12 +48,6 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati }) .WithTracing(tracing => { - if (builder.Environment.IsDevelopment()) - { - // We want to view all traces in development - tracing.SetSampler(new AlwaysOnSampler()); - } - tracing.AddAspNetCoreInstrumentation() // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package) //.AddGrpcClientInstrumentation() @@ -77,9 +65,7 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli if (useOtlpExporter) { - builder.Services.Configure(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) diff --git a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.Web/AspireSample.Web.csproj b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.Web/AspireSample.Web.csproj index 1480df4224..639d965d7b 100644 --- a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.Web/AspireSample.Web.csproj +++ b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.Web/AspireSample.Web.csproj @@ -1,7 +1,6 @@ - Exe net8.0 enable enable @@ -14,5 +13,5 @@ - + diff --git a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.Web/Components/Layout/MainLayout.razor b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.Web/Components/Layout/MainLayout.razor index c8f5e8fbcf..5a24bb1371 100644 --- a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.Web/Components/Layout/MainLayout.razor +++ b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.Web/Components/Layout/MainLayout.razor @@ -7,7 +7,7 @@
- About + About
diff --git a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.Web/Components/Layout/NavMenu.razor b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.Web/Components/Layout/NavMenu.razor index 12e6f848ab..97ece53c34 100644 --- a/docs/get-started/snippets/quickstart/AspireSample/AspireSample.Web/Components/Layout/NavMenu.razor +++ b/docs/get-started/snippets/quickstart/AspireSample/AspireSample.Web/Components/Layout/NavMenu.razor @@ -13,7 +13,7 @@ Home - +