You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/azureai/azureai-openai-integration.md
+16-14Lines changed: 16 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,22 @@
1
1
---
2
-
title: .NET Aspire Azure AI OpenAI integration
3
-
description: Learn how to use the .NET Aspire Azure AI OpenAI integration.
2
+
title: .NET Aspire Azure OpenAI integration
3
+
description: Learn how to use the .NET Aspire Azure OpenAI integration.
4
4
ms.topic: how-to
5
-
ms.date: 08/12/2024
5
+
ms.date: 09/27/2024
6
6
---
7
7
8
-
# .NET Aspire Azure AI OpenAI integration
8
+
# .NET Aspire Azure OpenAI integration
9
9
10
-
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.
10
+
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.
11
11
12
12
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).
13
13
14
14
## Get started
15
15
16
16
- Azure subscription: [create one for free](https://azure.microsoft.com/free/).
17
-
- Azure AI OpenAI or OpenAI account: [create an Azure OpenAI Service resource](/azure/ai-services/openai/how-to/create-resource).
17
+
- Azure OpenAI or OpenAI account: [create an Azure OpenAI Service resource](/azure/ai-services/openai/how-to/create-resource).
18
18
19
-
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.
19
+
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.
20
20
21
21
### [.NET CLI](#tab/dotnet-cli)
22
22
@@ -54,7 +54,7 @@ public class ExampleService(OpenAIClient client)
54
54
55
55
## App host usage
56
56
57
-
To add Azure AI hosting support to your <xref:Aspire.Hosting.IDistributedApplicationBuilder>, 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.
57
+
To add Azure hosting support to your <xref:Aspire.Hosting.IDistributedApplicationBuilder>, 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.
In your app host project, register an Azure AI OpenAI resource using the following methods, such as <xref:Aspire.Hosting.AzureOpenAIExtensions.AddAzureOpenAI%2A>:
74
+
In your app host project, register an Azure OpenAI resource using the following methods, such as <xref:Aspire.Hosting.AzureOpenAIExtensions.AddAzureOpenAI%2A>:
The .NET Aspire Azure AI OpenAI integration provides multiple options to configure the connection based on the requirements and conventions of your project.
95
+
The .NET Aspire Azure OpenAI integration provides multiple options to configure the connection based on the requirements and conventions of your project.
96
96
97
97
### Use a connection string
98
98
@@ -106,7 +106,7 @@ The connection string is retrieved from the `ConnectionStrings` configuration se
106
106
107
107
#### Account endpoint
108
108
109
-
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 <xref:Azure.Identity.DefaultAzureCredential> is used.
109
+
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 <xref:Azure.Identity.DefaultAzureCredential> is used.
110
110
111
111
```json
112
112
{
@@ -116,6 +116,8 @@ The recommended approach is to use an `Endpoint`, which works with the `AzureOpe
116
116
}
117
117
```
118
118
119
+
For more information, see [Use Azure OpenAI without keys](/azure/developer/ai/keyless-connections).
120
+
119
121
#### Connection string
120
122
121
123
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
132
134
133
135
### Use configuration providers
134
136
135
-
The .NET Aspire Azure AI OpenAI integration supports <xref:Microsoft.Extensions.Configuration>. 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:
137
+
The .NET Aspire Azure OpenAI integration supports <xref:Microsoft.Extensions.Configuration>. 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:
136
138
137
139
```json
138
140
{
@@ -171,14 +173,14 @@ builder.AddAzureAIOpenAI(
171
173
172
174
### Logging
173
175
174
-
The .NET Aspire Azure AI OpenAI integration uses the following log categories:
176
+
The .NET Aspire Azure OpenAI integration uses the following log categories:
175
177
176
178
-`Azure`
177
179
-`Azure.Core`
178
180
-`Azure.Identity`
179
181
180
182
## See also
181
183
182
-
-[Azure AI OpenAI docs](/azure/ai-services/openai/overview)
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:
- If the app host is running in "run" mode, a Redis container resource is added.
264
+
- If the app host is running in "publish" mode, a connection string is added.
265
+
266
+
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.
Copy file name to clipboardExpand all lines: docs/fundamentals/external-parameters.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: External parameters
3
3
description: Learn how to express parameters such as secrets, connection strings, and other configuration values that might vary between environments.
4
4
ms.topic: how-to
5
-
ms.date: 08/20/2024
5
+
ms.date: 09/27/2024
6
6
---
7
7
8
8
# External parameters
@@ -11,7 +11,7 @@ Environments provide context for the application to run in. Parameters express t
11
11
12
12
## Parameter values
13
13
14
-
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.
14
+
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.
15
15
16
16
Consider the following app host _:::no-loc text="Program.cs":::_ example file:
17
17
@@ -55,7 +55,7 @@ Parameters are represented in the manifest as a new primitive called `parameter.
55
55
56
56
## Secret values
57
57
58
-
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.
58
+
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.
59
59
60
60
Consider the following app host _:::no-loc text="Program.cs":::_ example file:
61
61
@@ -102,7 +102,7 @@ The manifest representation is as follows:
102
102
103
103
## Connection string values
104
104
105
-
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.
105
+
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.
106
106
107
107
> [!NOTE]
108
108
> 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);
Copy file name to clipboardExpand all lines: docs/get-started/aspire-overview.md
+9-17Lines changed: 9 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: .NET Aspire overview
3
3
description: Learn about .NET Aspire, an application stack designed to improve the experience of building cloud-native applications.
4
-
ms.date: 08/12/2024
4
+
ms.date: 09/27/2024
5
5
---
6
6
7
7
# .NET Aspire overview
@@ -27,7 +27,7 @@ A _distributed application_ is one that uses computational _resources_ across mu
27
27
28
28
-[**Orchestration**](#orchestration): .NET Aspire provides features for running and connecting multi-project applications and their dependencies for [local development environments](../fundamentals/networking-overview.md).
29
29
-[**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.
30
-
-[**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.
30
+
-[**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.
31
31
32
32
## Orchestration
33
33
@@ -36,7 +36,7 @@ In .NET Aspire, orchestration primarily focuses on enhancing the _local developm
36
36
.NET Aspire orchestration assists with the following concerns:
37
37
38
38
-**App composition**: Specify the .NET projects, containers, executables, and cloud resources that make up the application.
39
-
-**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.
39
+
-**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.
40
40
41
41
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:
For more information, see [.NET Aspire orchestration overview](../fundamentals/app-host-overview.md).
57
57
58
+
> [!IMPORTANT]
59
+
> 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).
60
+
58
61
## .NET Aspire integrations
59
62
60
63
[.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.
61
64
62
-
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.
65
+
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.
63
66
64
67
For example, consider the following code using the .NET Aspire Service Bus integration:
65
68
@@ -71,24 +74,13 @@ The <xref:Microsoft.Extensions.Hosting.AspireServiceBusExtensions.AddAzureServic
71
74
72
75
- Registers a <xref:Azure.Messaging.ServiceBus.ServiceBusClient> as a singleton in the DI container for connecting to Azure Service Bus.
73
76
- Applies `ServiceBusClient` configurations either inline through code or through configuration.
74
-
- Enables corresponding health checks, logging and telemetry specific to the Azure Service Bus usage.
77
+
- Enables corresponding health checks, logging, and telemetry specific to the Azure Service Bus usage.
75
78
76
79
A full list of available integrations is detailed on the [.NET Aspire integrations](../fundamentals/integrations-overview.md) overview page.
77
80
78
81
## Project templates and tooling
79
82
80
-
.NET Aspire projects follow a standardized structure designed around the default .NET Aspire project templates. Most .NET Aspire projects have at least three projects:
81
-
82
-
-**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.
83
-
-**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.
84
-
-**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.
85
-
86
-
There are currently two .NET Aspire starter templates available to help you get started with this structure:
87
-
88
-
-**.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.
89
-
-**.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.
90
-
91
-
For more information, see [.NET Aspire setup and tooling](../fundamentals/setup-tooling.md).
83
+
.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).
92
84
93
85
.NET Aspire templates also include boilerplate extension methods that handle common service configurations for you:
0 commit comments