diff --git a/docs/azureai/azureai-openai-integration.md b/docs/azureai/azureai-openai-integration.md index 65c9ef0d1c..e9ccb59e95 100644 --- a/docs/azureai/azureai-openai-integration.md +++ b/docs/azureai/azureai-openai-integration.md @@ -1,22 +1,22 @@ --- -title: .NET Aspire Azure AI OpenAI integration -description: Learn how to use the .NET Aspire Azure AI OpenAI integration. +title: .NET Aspire Azure OpenAI integration +description: Learn how to use the .NET Aspire Azure OpenAI integration. ms.topic: how-to -ms.date: 08/12/2024 +ms.date: 09/27/2024 --- -# .NET Aspire Azure AI OpenAI integration +# .NET Aspire Azure OpenAI integration -In this article, you learn how to use the .NET Aspire Azure AI OpenAI client. The `Aspire.Azure.AI.OpenAI` library is used to register an `OpenAIClient` in the dependency injection (DI) container for consuming Azure AI OpenAI or OpenAI functionality. It enables corresponding logging and telemetry. +In this article, you learn how to use the .NET Aspire Azure OpenAI client. The `Aspire.Azure.AI.OpenAI` library is used to register an `OpenAIClient` in the dependency injection (DI) container for consuming Azure OpenAI or OpenAI functionality. It enables corresponding logging and telemetry. For more information on using the `OpenAIClient`, see [Quickstart: Get started generating text using Azure OpenAI Service](/azure/ai-services/openai/quickstart?tabs=command-line%2Cpython&pivots=programming-language-csharp). ## Get started - Azure subscription: [create one for free](https://azure.microsoft.com/free/). -- Azure AI OpenAI or OpenAI account: [create an Azure OpenAI Service resource](/azure/ai-services/openai/how-to/create-resource). +- Azure OpenAI or OpenAI account: [create an Azure OpenAI Service resource](/azure/ai-services/openai/how-to/create-resource). -To get started with the .NET Aspire Azure AI OpenAI integration, install the [Aspire.Azure.AI.OpenAI](https://www.nuget.org/packages/Aspire.Azure.AI.OpenAI) NuGet package in the client-consuming project, i.e., the project for the application that uses the Azure AI OpenAI client. +To get started with the .NET Aspire Azure OpenAI integration, install the [Aspire.Azure.AI.OpenAI](https://www.nuget.org/packages/Aspire.Azure.AI.OpenAI) NuGet package in the client-consuming project, i.e., the project for the application that uses the Azure OpenAI client. ### [.NET CLI](#tab/dotnet-cli) @@ -54,7 +54,7 @@ public class ExampleService(OpenAIClient client) ## App host usage -To add Azure AI hosting support to your , install the [Aspire.Hosting.Azure.CognitiveServices](https://www.nuget.org/packages/Aspire.Hosting.Azure.CognitiveServices) NuGet package in the [app host](xref:aspire/app-host) project. +To add Azure hosting support to your , install the [Aspire.Hosting.Azure.CognitiveServices](https://www.nuget.org/packages/Aspire.Hosting.Azure.CognitiveServices) NuGet package in the [app host](xref:aspire/app-host) project. ### [.NET CLI](#tab/dotnet-cli) @@ -71,7 +71,7 @@ dotnet add package Aspire.Hosting.Azure.CognitiveServices --- -In your app host project, register an Azure AI OpenAI resource using the following methods, such as : +In your app host project, register an Azure OpenAI resource using the following methods, such as : ```csharp var builder = DistributedApplication.CreateBuilder(args); @@ -92,7 +92,7 @@ builder.AddAzureAIOpenAI("openAiConnectionName"); ## Configuration -The .NET Aspire Azure AI OpenAI integration provides multiple options to configure the connection based on the requirements and conventions of your project. +The .NET Aspire Azure OpenAI integration provides multiple options to configure the connection based on the requirements and conventions of your project. ### Use a connection string @@ -106,7 +106,7 @@ The connection string is retrieved from the `ConnectionStrings` configuration se #### Account endpoint -The recommended approach is to use an `Endpoint`, which works with the `AzureOpenAISettings.Credential` property to establish a connection. If no credential is configured, the is used. +The recommended approach is to use an **Endpoint**, which works with the `AzureOpenAISettings.Credential` property to establish a connection. If no credential is configured, the is used. ```json { @@ -116,6 +116,8 @@ The recommended approach is to use an `Endpoint`, which works with the `AzureOpe } ``` +For more information, see [Use Azure OpenAI without keys](/azure/developer/ai/keyless-connections). + #### Connection string Alternatively, a custom connection string can be used. @@ -132,7 +134,7 @@ In order to connect to the non-Azure OpenAI service, drop the `Endpoint` propert ### Use configuration providers -The .NET Aspire Azure AI OpenAI integration supports . It loads the `AzureOpenAISettings` from configuration by using the `Aspire:Azure:AI:OpenAI` key. Example _:::no-loc text="appsettings.json":::_ that configures some of the options: +The .NET Aspire Azure OpenAI integration supports . It loads the `AzureOpenAISettings` from configuration by using the `Aspire:Azure:AI:OpenAI` key. Example _:::no-loc text="appsettings.json":::_ that configures some of the options: ```json { @@ -171,7 +173,7 @@ builder.AddAzureAIOpenAI( ### Logging -The .NET Aspire Azure AI OpenAI integration uses the following log categories: +The .NET Aspire Azure OpenAI integration uses the following log categories: - `Azure` - `Azure.Core` @@ -179,6 +181,6 @@ The .NET Aspire Azure AI OpenAI integration uses the following log categories: ## See also -- [Azure AI OpenAI docs](/azure/ai-services/openai/overview) +- [Azure OpenAI docs](/azure/ai-services/openai/overview) - [.NET Aspire integrations](../fundamentals/integrations-overview.md) - [.NET Aspire GitHub repo](https://github.com/dotnet/aspire) diff --git a/docs/database/azure-cosmos-db-integration.md b/docs/database/azure-cosmos-db-integration.md index beb6e5fcdc..eb5b706815 100644 --- a/docs/database/azure-cosmos-db-integration.md +++ b/docs/database/azure-cosmos-db-integration.md @@ -35,7 +35,7 @@ For more information, see [dotnet add package](/dotnet/core/tools/dotnet-add-pac In the _:::no-loc text="Program.cs":::_ file of your client-consuming project, call the extension to register a for use via the dependency injection container. ```csharp -builder.AddAzureCosmosClient("cosmosdb"); +builder.AddAzureCosmosClient("cosmosConnectionName"); ``` You can then retrieve the `CosmosClient` instance using dependency injection. For example, to retrieve the client from a service: @@ -51,7 +51,7 @@ For more information on using the , se ## App host usage -To add Azure Cosmos DB hosting support to your , install the [Aspire.Hosting.Azure.CosmosDB](https://www.nuget.org/packages/Aspire.Hosting.Azure.CosmosDB) NuGet package in the [app host](xref:aspire/app-host) project. +To add Azure Cosmos DB hosting support to your , install the [Aspire.Hosting.Azure.CosmosDB](https://www.nuget.org/packages/Aspire.Hosting.Azure.CosmosDB) NuGet package in the [app host](xref:aspire/app-host) project. This is helpful if you want Aspire to provision a new Azure Cosmos DB account for you, or if you want to use the Azure Cosmos DB emulator. If you want to use an Azure Cosmos DB account that is already provisioned, there's no need to add it to the app host project. ### [.NET CLI](#tab/dotnet-cli) @@ -73,8 +73,8 @@ In your app host project, register the .NET Aspire Azure Cosmos DB integration a ```csharp var builder = DistributedApplication.CreateBuilder(args); -var cosmos = builder.AddAzureCosmosDB("cosmos"); -var cosmosdb = cosmos.AddDatabase("cosmosdb"); +var cosmos = builder.AddAzureCosmosDB("myNewCosmosAccountName"); +var cosmosdb = cosmos.AddDatabase("myCosmosDatabaseName"); var exampleProject = builder.AddProject() .WithReference(cosmosdb); @@ -89,14 +89,14 @@ var exampleProject = builder.AddProject() ## Configuration -The .NET Aspire Azure Cosmos DB library provides multiple options to configure the Azure Cosmos DB connection based on the requirements and conventions of your project. +The .NET Aspire Azure Cosmos DB library provides multiple options to configure the `CosmosClient` connection based on the requirements and conventions of your project. ### Use a connection string -When using a connection string from the `ConnectionStrings` configuration section, you can provide the name of the connection string when calling `builder.AddAzureCosmosDB`: +When using a connection string from the `ConnectionStrings` configuration section, you can provide the name of the connection string when calling `builder.AddAzureCosmosClient`: ```csharp -builder.AddAzureCosmosDB("cosmosConnectionName"); +builder.AddAzureCosmosClient("cosmosConnectionName"); ``` And then the connection string will be retrieved from the `ConnectionStrings` configuration section: @@ -152,15 +152,15 @@ The .NET Aspire Azure Cosmos DB integration supports ` delegate to set up some or all the options inline, for example to disable tracing from code: ```csharp -builder.AddAzureCosmosDB( +builder.AddAzureCosmosClient( "cosmosConnectionName", static settings => settings.DisableTracing = true); ``` -You can also set up the using the optional `Action configureClientOptions` parameter of the `AddAzureCosmosDB` method. For example to set the user-agent header suffix for all requests issues by this client: +You can also set up the using the optional `Action configureClientOptions` parameter of the `AddAzureCosmosClient` method. For example to set the user-agent header suffix for all requests issues by this client: ```csharp -builder.AddAzureCosmosDB( +builder.AddAzureCosmosClient( "cosmosConnectionName", configureClientOptions: clientOptions => clientOptions.ApplicationName = "myapp"); @@ -178,12 +178,36 @@ The .NET Aspire Azure Cosmos DB integration uses the following log categories: - Azure-Cosmos-Operation-Request-Diagnostics +In addition to getting Azure Cosmos DB request diagnostics for failed requests, you can configure latency thresholds to determine which successful Azure Cosmos DB request diagnostics will be logged. The default values are 100 ms for point operations and 500 ms for non point operations. + +```csharp +builder.AddAzureCosmosClient( + "cosmosConnectionName", + configureClientOptions: + clientOptions => { + clientOptions.CosmosClientTelemetryOptions = new() + { + CosmosThresholdOptions = new() + { + PointOperationLatencyThreshold = TimeSpan.FromMilliseconds(50), + NonPointOperationLatencyThreshold = TimeSpan.FromMilliseconds(300) + } + }; + }); +``` + ### Tracing The .NET Aspire Azure Cosmos DB integration will emit the following tracing activities using OpenTelemetry: - Azure.Cosmos.Operation +Azure Cosmos DB tracing is currently in preview, so you must set the experimental switch to ensure traces are emitted. [Learn more about tracing in Azure Cosmos DB.](/azure/cosmos-db/nosql/sdk-observability#trace-attributes) + +```csharp +AppContext.SetSwitch("Azure.Experimental.EnableActivitySource", true); +``` + ### Metrics The .NET Aspire Azure Cosmos DB integration currently doesn't support metrics by default due to limitations with the Azure SDK. diff --git a/docs/fundamentals/app-host-overview.md b/docs/fundamentals/app-host-overview.md index f45ed2d7ad..1c68a07eff 100644 --- a/docs/fundamentals/app-host-overview.md +++ b/docs/fundamentals/app-host-overview.md @@ -243,6 +243,28 @@ private static IResourceBuilder RunWithStableNodeName( } ``` +The execution context is often used to conditionally add resources or connection strings that point to existing resources. Consider the following example that demonstrates conditionally adding Redis or a connection string based on the execution context: + +```csharp +var builder = DistributedApplication.CreateBuilder(args); + +var redis = builder.ExecutionContext.IsRunMode + ? builder.AddRedis("redis") + : builder.AddConnectionString("redis"); + +builder.AddProject("api") + .WithReference(redis); + +builder.Build().Run(); +``` + +In the preceding code: + +- If the app host is running in "run" mode, a Redis container resource is added. +- If the app host is running in "publish" mode, a connection string is added. + +This logic can easily be inverted to connect to an existing Redis resource when you're running locally, and create a new Redis resource when you're publishing. + ## See also - [.NET Aspire integrations overview](integrations-overview.md) diff --git a/docs/fundamentals/external-parameters.md b/docs/fundamentals/external-parameters.md index 2d7aa84e7d..cd7439c28a 100644 --- a/docs/fundamentals/external-parameters.md +++ b/docs/fundamentals/external-parameters.md @@ -2,7 +2,7 @@ title: External parameters description: Learn how to express parameters such as secrets, connection strings, and other configuration values that might vary between environments. ms.topic: how-to -ms.date: 08/20/2024 +ms.date: 09/27/2024 --- # External parameters @@ -11,7 +11,7 @@ Environments provide context for the application to run in. Parameters express t ## Parameter values -Parameter values are read from the `Parameters` section of the app host's configuration and are used to provide values to the app while running locally. When deploying the app, the value will be asked for the parameter value. +Parameter values are read from the `Parameters` section of the app host's configuration and are used to provide values to the app while running locally. When you publish the app, if the value isn't available you're prompted to provide it. Consider the following app host _:::no-loc text="Program.cs":::_ example file: @@ -55,7 +55,7 @@ Parameters are represented in the manifest as a new primitive called `parameter. ## Secret values -Parameters can be used to model secrets. When a parameter is marked as a secret, this is a hint to the manifest that the value should be treated as a secret. When deploying, the value will be prompted for and stored in a secure location. When running locally, the value will be read from the `Parameters` section of the app host configuration. +Parameters can be used to model secrets. When a parameter is marked as a secret, it serves as a hint to the manifest that the value should be treated as a secret. When you publish the app, the value is prompted for and stored in a secure location. When you run the app locally, the value is read from the `Parameters` section of the app host configuration. Consider the following app host _:::no-loc text="Program.cs":::_ example file: @@ -102,7 +102,7 @@ The manifest representation is as follows: ## Connection string values -Parameters can be used to model connection strings. When deploying, the value will be prompted for and stored in a secure location. When running locally, the value will be read from the `ConnectionStrings` section of the app host configuration. +Parameters can be used to model connection strings. When you publish the app, the value is prompted for and stored in a secure location. When you run the app locally, the value is read from the `ConnectionStrings` section of the app host configuration. > [!NOTE] > Connection strings are used to represent a wide range of connection information including database connections, message brokers, and other services. In .NET Aspire nomenclature, the term "connection string" is used to represent any kind of connection information. @@ -114,7 +114,7 @@ var builder = DistributedApplication.CreateBuilder(args); var redis = builder.AddConnectionString("redis"); -builder.AddProject("api") +builder.AddProject("api") .WithReference(redis); builder.Build().Run(); @@ -151,7 +151,7 @@ The value for the `insertionRows` parameter is read from the `Parameters` sectio :::code language="json" source="snippets/params/Parameters.AppHost/appsettings.json"::: -The `Parameters_ApiService` project consumes the `insertionRows` parameter, consider the _:::no-loc text="Program.cs":::_ example file: +The `Parameters_ApiService` project consumes the `insertionRows` parameter. Consider the _:::no-loc text="Program.cs":::_ example file: :::code source="snippets/params/Parameters.ApiService/Program.cs"::: diff --git a/docs/get-started/aspire-overview.md b/docs/get-started/aspire-overview.md index 4929bc53ab..0351c028f8 100644 --- a/docs/get-started/aspire-overview.md +++ b/docs/get-started/aspire-overview.md @@ -1,7 +1,7 @@ --- title: .NET Aspire overview description: Learn about .NET Aspire, an application stack designed to improve the experience of building cloud-native applications. -ms.date: 08/12/2024 +ms.date: 09/27/2024 --- # .NET Aspire overview @@ -27,7 +27,7 @@ A _distributed application_ is one that uses computational _resources_ across mu - [**Orchestration**](#orchestration): .NET Aspire provides features for running and connecting multi-project applications and their dependencies for [local development environments](../fundamentals/networking-overview.md). - [**Integrations**](#net-aspire-integrations): .NET Aspire integrations are NuGet packages for commonly used services, such as Redis or Postgres, with standardized interfaces ensuring they connect consistently and seamlessly with your app. -- [**Tooling**](#project-templates-and-tooling): .NET Aspire comes with project templates and tooling experiences for Visual Studio, Visual Studio Code, and the [dotnet CLI](/dotnet/core/tools/) to help you create and interact with .NET Aspire projects. +- [**Tooling**](#project-templates-and-tooling): .NET Aspire comes with project templates and tooling experiences for Visual Studio, Visual Studio Code, and the [.NET CLI](/dotnet/core/tools/) to help you create and interact with .NET Aspire projects. ## Orchestration @@ -36,7 +36,7 @@ In .NET Aspire, orchestration primarily focuses on enhancing the _local developm .NET Aspire orchestration assists with the following concerns: - **App composition**: Specify the .NET projects, containers, executables, and cloud resources that make up the application. -- **Service discovery and connection string management**: The app host manages injecting the right connection strings or network configurations and service discovery information to simplify the developer experience. +- **Service discovery and connection string management**: The app host manages to inject the right connection strings or network configurations and service discovery information to simplify the developer experience. For example, using .NET Aspire, the following code creates a local Redis container resource and configures the appropriate connection string in the `"frontend"` project with only two helper method calls: @@ -55,11 +55,14 @@ builder.AddProject("frontend") For more information, see [.NET Aspire orchestration overview](../fundamentals/app-host-overview.md). +> [!IMPORTANT] +> The call to `AddRedis` creates a new Redis container in your local dev environment. If you'd rather use an existing Redis instance, you can use the `AddConnectionString` method to reference an existing connection string. For more information, see [Reference existing resources](../fundamentals/app-host-overview.md#reference-existing-resources). + ## .NET Aspire integrations [.NET Aspire integrations](../fundamentals/integrations-overview.md) are NuGet packages designed to simplify connections to popular services and platforms, such as Redis or PostgreSQL. .NET Aspire integrations handle many cloud-native concerns for you through standardized configuration patterns, such as adding health checks and telemetry. Integrations are two-fold, in that one side represents the service you're connecting to, and the other side represents the client or consumer of that service. In other words, for each hosting package there's a corresponding client package that handles the service connection. -Each integration is designed to work with .NET Aspire orchestration, and their configurations are injected automatically by simply referencing named resources. In other words, if _Example.ServiceFoo_ references _Example.ServiceBar_, _Example.ServiceFoo_ inherits the integration's required configurations to allow them to communicate with each other automatically. +Each integration is designed to work with .NET Aspire orchestration, and their configurations are injected automatically by [referencing named resources](../fundamentals/app-host-overview.md#reference-resources). In other words, if _Example.ServiceFoo_ references _Example.ServiceBar_, _Example.ServiceFoo_ inherits the integration's required configurations to allow them to communicate with each other automatically. For example, consider the following code using the .NET Aspire Service Bus integration: @@ -71,24 +74,13 @@ The as a singleton in the DI container for connecting to Azure Service Bus. - Applies `ServiceBusClient` configurations either inline through code or through configuration. -- Enables corresponding health checks, logging and telemetry specific to the Azure Service Bus usage. +- Enables corresponding health checks, logging, and telemetry specific to the Azure Service Bus usage. A full list of available integrations is detailed on the [.NET Aspire integrations](../fundamentals/integrations-overview.md) overview page. ## Project templates and tooling -.NET Aspire projects follow a standardized structure designed around the default .NET Aspire project templates. Most .NET Aspire projects have at least three projects: - -- **MyFirstAspireApp**: Your starter app, which could be any common .NET project such as a Blazor UI or Minimal API. You can add more projects to your app as it expands and manage orchestration between them using the **.AppHost** and **.ServiceDefaults** project. -- **MyFirstAspireApp.AppHost**: The **.AppHost** project is used to manage the high level orchestration concerns of the app. Orchestration involves putting together various parts of your app, like APIs, service containers, and executables, and setting up how they find and communicate with each other. -- **MyFirstAspireApp.ServiceDefaults**: The **.ServiceDefaults** project contains default .NET Aspire project configurations that can be extended and customized as needed. These configurations include concerns such as setting up health checks, OpenTelemetry settings, and more. - -There are currently two .NET Aspire starter templates available to help you get started with this structure: - -- **.NET Aspire Application**: A basic starter template that only includes the **AspireSample.AppHost** and **AspireSample.ServiceDefaults** projects. This template is designed to only provide the essentials for you to build off of. -- **.NET Aspire Starter Application**: This template includes the **AspireSample.AppHost** and **AspireSample.ServiceDefaults** projects, but also includes boilerplate UI and API projects. These projects are pre-configured with service discovery and other basic examples of common .NET Aspire functionality. - -For more information, see [.NET Aspire setup and tooling](../fundamentals/setup-tooling.md). +.NET Aspire provides a set of project templates and tooling experiences for Visual Studio, Visual Studio Code, and the [.NET CLI](/dotnet/core/tools/). These templates are designed to help you create and interact with .NET Aspire projects. The templates are opinionated and come with a set of defaults that help you get started quickly. They include boilerplate code and configurations that are common to cloud-native apps, such as telemetry, health checks, and service discovery. For more information, see [.NET Aspire project templates](../fundamentals/setup-tooling.md#net-aspire-project-templates). .NET Aspire templates also include boilerplate extension methods that handle common service configurations for you: diff --git a/docs/get-started/build-your-first-aspire-app.md b/docs/get-started/build-your-first-aspire-app.md index 86aa9df589..e41f59b73d 100644 --- a/docs/get-started/build-your-first-aspire-app.md +++ b/docs/get-started/build-your-first-aspire-app.md @@ -1,16 +1,16 @@ --- -title: Build your first .NET Aspire project -description: Learn how to build your first .NET Aspire project using the .NET Aspire Started Application template. -ms.date: 06/12/2024 +title: Build your first .NET Aspire solution +description: Learn how to build your first .NET Aspire solution using the .NET Aspire Started Application template. +ms.date: 09/27/2024 ms.topic: quickstart zone_pivot_groups: dev-environment --- -# Quickstart: Build your first .NET Aspire project +# Quickstart: Build your first .NET Aspire solution Cloud-native apps often require connections to various services such as databases, storage and caching solutions, messaging providers, or other web services. .NET Aspire is designed to streamline connections and configurations between these types of services. This quickstart shows how to create a .NET Aspire Starter Application template solution. -In this quickstart, you'll explore the following tasks: +In this quickstart, you explore the following tasks: > [!div class="checklist"] > @@ -43,7 +43,7 @@ To create a new .NET Aspire Starter Application, you can use either Visual Studi ## Test the app locally -The sample app is now ready for testing. You want to verify the following: +The sample app is now ready for testing. You want to verify the following conditions: - Weather data is retrieved from the API project using service discovery and displayed on the weather page. - Subsequent requests are handled via the output caching configured by the .NET Aspire Redis integration. @@ -53,9 +53,9 @@ The sample app is now ready for testing. You want to verify the following: In Visual Studio, set the **AspireSample.AppHost** project as the startup project by right-clicking on the project in the **Solution Explorer** and selecting **Set as Startup Project**. Then, press F5 to run the app. :::zone-end -:::zone pivot="vscode,dotnet-cli" +:::zone pivot="dotnet-cli" -If you haven't already trusted the ASP.NET Core localhost certificate, you will need to trust the certificate before running the app: +You need to trust the ASP.NET Core localhost certificate before running the app. Run the following command: ```dotnetcli dotnet dev-certs https --trust @@ -66,9 +66,12 @@ For more information, see [Troubleshoot untrusted localhost certificate in .NET :::zone-end :::zone pivot="vscode" -In Visual Studio Code, press F5 to run the app. You'll be prompted to select which language, and C# will be suggested, select C# and then select the **AspireSample.AppHost** project with the **Default Configuration**: +In Visual Studio Code, press F5 to launch the app. You're prompted to select which language, and C# is suggested. Select C# and then select the **AspireSample.AppHost** project with the **Default Configuration**: + +:::image type="content" loc-scope="vs-code" source="media/vscode-run.png" lightbox="media/vscode-run.png" alt-text="A screenshot of the Visual Studio Code launch configuration for the AspireSample.AppHost project."::: -:::image type="content" loc-scope="vs-code" source="media/vscode-run.png" lightbox="media/vscode-run.png" alt-text="A screenshot of the Visual Studio Code run configuration for the AspireSample.AppHost project."::: +> [!TIP] +> If you're on MacOS and using Safari, when your browser opens if the page is blank, you might need to manually refresh the page. :::zone-end :::zone pivot="dotnet-cli" @@ -81,7 +84,7 @@ For more information, see [dotnet run](/dotnet/core/tools/dotnet-run). :::zone-end -1. The app displays the .NET Aspire dashboard in the browser. We'll look at the dashboard in more detail later. For now, find the **webfrontend** project in the list of resources and select the project's **localhost** endpoint. +1. The app displays the .NET Aspire dashboard in the browser. You look at the dashboard in more detail later. For now, find the **webfrontend** project in the list of resources and select the project's **localhost** endpoint. :::image type="content" source="media/aspire-dashboard-webfrontend.png" lightbox="media/aspire-dashboard-webfrontend.png" alt-text="A screenshot of the .NET Aspire Dashboard, highlighting the webfrontend project's localhost endpoint."::: @@ -92,27 +95,27 @@ For more information, see [dotnet run](/dotnet/core/tools/dotnet-run). :::image type="content" source="media/weather-page.png" lightbox="media/weather-page.png" alt-text="The Weather page of the webfrontend app showing the weather data retrieved from the API."::: -🤓 Congratulations! You created and ran your first .NET Aspire project! To stop the app, you can close the browser window. +🤓 Congratulations! You created and ran your first .NET Aspire solution! To stop the app, close the browser window. :::zone pivot="visual-studio" -In Visual Studio, select the **Stop Debugging** from the **Debug** menu to stop the app. +To stop the app in Visual Studio, select the **Stop Debugging** from the **Debug** menu. :::zone-end :::zone pivot="vscode" -In Visual Studio Code, press Shift + F5 to stop the app, or select the **Stop** button at the top center of the window: +To stop the app in Visual Studio Code, press Shift + F5, or select the **Stop** button at the top center of the window: :::image type="content" loc-scope="vs-code" source="media/vscode-stop.png" lightbox="media/vscode-stop.png" alt-text="A screenshot of the Visual Studio Code stop button."::: :::zone-end :::zone pivot="dotnet-cli" -Press Ctrl + C in the terminal window to stop the app. +To stop the app, press Ctrl + C in the terminal window. :::zone-end -Now let's investigate the structure and other features of your new .NET Aspire project. +Next, investigate the structure and other features of your new .NET Aspire solution. ## Explore the .NET Aspire dashboard @@ -120,7 +123,7 @@ When you run a .NET Aspire project, a dashboard launches that you use to monitor :::image type="content" source="media/aspire-dashboard.png" lightbox="media/aspire-dashboard.png" alt-text="A screenshot of the .NET Aspire Dashboard, depicting the Projects tab."::: -Visit each link on the left navigation to view different information about the .NET Aspire project: +Visit each page using the left navigation to view different information about the .NET Aspire resources: - **Resources**: Lists basic information for all of the individual .NET projects in your .NET Aspire project, such as the app state, endpoint addresses, and the environment variables that were loaded in. - **Console**: Displays the console output from each of the projects in your app. @@ -144,7 +147,7 @@ The solution consists of the following projects: - **AspireSample.ServiceDefaults**: A .NET Aspire shared project to manage configurations that are reused across the projects in your solution related to [resilience](/dotnet/core/resilience/http-resilience), [service discovery](../service-discovery/overview.md), and [telemetry](../fundamentals/telemetry.md). - **AspireSample.Web**: An ASP.NET Core Blazor App project with default .NET Aspire service configurations, this project depends on the **AspireSample.ServiceDefaults** project. For more information, see [.NET Aspire service defaults](../fundamentals/service-defaults.md). -Your _AspireSample_ directory should resemble the following: +Your _AspireSample_ directory should resemble the following structure: [!INCLUDE [template-directory-structure](../includes/template-directory-structure.md)] @@ -173,6 +176,9 @@ If you've used either the [.NET Generic Host](/dotnet/core/extensions/generic-ho Finally, the app is built and run. The method is provided by the .NET Aspire SDK, and is responsible for starting the app and all of its dependencies. For more information, see [.NET Aspire orchestration overview](../fundamentals/app-host-overview.md). +> [!TIP] +> The call to `AddRedis` creates a local Redis container for the app to use. If you'd rather simply point to an existing Redis instance, you can use the `AddConnectionString` method to reference an existing connection string. For more information, see [Reference existing resources](../fundamentals/app-host-overview.md#reference-existing-resources). + ### .NET Aspire service defaults project The _*.ServiceDefaults_ project is a shared project that's used to manage configurations that are reused across the projects in your solution. This project ensures that all dependent services share the same resilience, service discovery, and OpenTelemetry configuration. A shared .NET Aspire project file contains the `IsAspireSharedProject` property set as `true`: @@ -183,13 +189,13 @@ The service defaults project exposes an extension method on the that's used to communicate with the API project. :::code source="snippets/quickstart/AspireSample/AspireSample.Web/WeatherApiClient.cs"::: -The `HttpClient` is configured to use service discovery, consider the following code from the _:::no-loc text="Program.cs":::_ file of the _AspireSample.Web_ project: +The `HttpClient` is configured to use service discovery. Consider the following code from the _:::no-loc text="Program.cs":::_ file of the _AspireSample.Web_ project: :::code source="snippets/quickstart/AspireSample/AspireSample.Web/Program.cs" highlight="7-8,14-19"::: @@ -197,7 +203,7 @@ The preceding code: - Calls `AddServiceDefaults`, configuring the shared defaults for the app. - Calls with the same `connectionName` that was used when adding the Redis container `"cache"` to the application model. This configures the app to use Redis for output caching. -- Calls and configures the to be `"https+http://apiservice"`. This is the name that was used when adding the API project to the application model, and with service discovery configured, it will automatically resolve to the correct address to the API project. +- Calls and configures the to be `"https+http://apiservice"`. This is the name that was used when adding the API project to the application model, and with service discovery configured, it automatically resolves to the correct address to the API project. For more information, see [Make HTTP requests with the `HttpClient`](/dotnet/fundamentals/networking/http/httpclient) class. diff --git a/docs/toc.yml b/docs/toc.yml index 7570052511..be96090717 100644 --- a/docs/toc.yml +++ b/docs/toc.yml @@ -104,7 +104,7 @@ items: href: messaging/kafka-integration.md - name: Azure items: - - name: Azure AI OpenAI + - name: Azure OpenAI displayName: azure ai,openai href: azureai/azureai-openai-integration.md - name: Azure Search Documents