Skip to content

Commit 7e988a1

Browse files
VarorbcMackinnonBuck
authored andcommitted
Update Aspire (#6858)
* Update Aspire * Update Aspire template README --------- Co-authored-by: Mackinnon Buck <[email protected]>
1 parent a1d7dfd commit 7e988a1

File tree

31 files changed

+112
-125
lines changed

31 files changed

+112
-125
lines changed

src/ProjectTemplates/GeneratedContent.targets

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
<TemplatePackageVersion_MicrosoftExtensionsAI>9.9.1</TemplatePackageVersion_MicrosoftExtensionsAI>
4545
<TemplatePackageVersion_MicrosoftExtensionsAIOpenAI>9.9.1-preview.1.25474.6</TemplatePackageVersion_MicrosoftExtensionsAIOpenAI>
4646

47-
<TemplatePackageVersion_Aspire>9.4.0</TemplatePackageVersion_Aspire>
48-
<TemplatePackageVersion_Aspire_Preview>9.4.0-preview.1.25378.8</TemplatePackageVersion_Aspire_Preview>
49-
<TemplatePackageVersion_AzureAIOpenAI>2.3.0-beta.1</TemplatePackageVersion_AzureAIOpenAI>
47+
<TemplatePackageVersion_Aspire>9.5.0</TemplatePackageVersion_Aspire>
48+
<TemplatePackageVersion_Aspire_Preview>9.5.0-preview.1.25474.7</TemplatePackageVersion_Aspire_Preview>
49+
<TemplatePackageVersion_AzureAIOpenAI>2.3.0-beta.2</TemplatePackageVersion_AzureAIOpenAI>
5050
<TemplatePackageVersion_AzureAIProjects>1.0.0-beta.9</TemplatePackageVersion_AzureAIProjects>
5151
<TemplatePackageVersion_AzureIdentity>1.14.0</TemplatePackageVersion_AzureIdentity>
5252
<TemplatePackageVersion_AzureSearchDocuments>11.6.1</TemplatePackageVersion_AzureSearchDocuments>

src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/.template.config/template.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "http://json.schemastore.org/template",
33
"author": "Microsoft",
4-
"classifications": [ "Common", "AI", "Web", "Blazor", ".NET Aspire" ],
4+
"classifications": [ "Common", "AI", "Web", "Blazor", "Aspire" ],
55
"identity": "Microsoft.Extensions.AI.Templates.WebChat.CSharp",
66
"name": "AI Chat Web App",
77
"description": "A project template for creating an AI chat application, which uses retrieval-augmented generation (RAG) to chat with your own data.",
@@ -183,7 +183,7 @@
183183
"displayName": "Use Aspire orchestration",
184184
"datatype": "bool",
185185
"defaultValue": "false",
186-
"description": "Create the project as a distributed application using .NET Aspire."
186+
"description": "Create the project as a distributed application using Aspire."
187187
},
188188
"IsAspire": {
189189
"type": "computed",

src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData-CSharp.AppHost/ChatWithCustomData-CSharp.AppHost.csproj.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<TargetFramework>net9.0</TargetFramework>
88
<ImplicitUsings>enable</ImplicitUsings>
99
<Nullable>enable</Nullable>
10-
<IsAspireHost>true</IsAspireHost>
1110
<UserSecretsId>b2f4f5e9-1083-472c-8c3b-f055ac67ba54</UserSecretsId>
1211
</PropertyGroup>
1312

src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData-CSharp.AppHost/Properties/launchSettings.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"environmentVariables": {
1010
"ASPNETCORE_ENVIRONMENT": "Development",
1111
"DOTNET_ENVIRONMENT": "Development",
12-
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21000",
13-
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22000"
12+
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21000",
13+
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22000"
1414
}
1515
},
1616
"http": {
@@ -21,8 +21,8 @@
2121
"environmentVariables": {
2222
"ASPNETCORE_ENVIRONMENT": "Development",
2323
"DOTNET_ENVIRONMENT": "Development",
24-
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19000",
25-
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20000"
24+
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19000",
25+
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20000"
2626
}
2727
}
2828
}

src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData-CSharp.ServiceDefaults/Extensions.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010

1111
namespace Microsoft.Extensions.Hosting;
1212

13-
// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
13+
// Adds common Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
1414
// This project should be referenced by each service project in your solution.
1515
// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
1616
public static class Extensions
1717
{
18+
private const string HealthEndpointPath = "/health";
19+
private const string AlivenessEndpointPath = "/alive";
20+
1821
public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
1922
{
2023
builder.ConfigureOpenTelemetry();
@@ -64,7 +67,12 @@ public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) w
6467
.WithTracing(tracing =>
6568
{
6669
tracing.AddSource(builder.Environment.ApplicationName)
67-
.AddAspNetCoreInstrumentation()
70+
.AddAspNetCoreInstrumentation(tracing =>
71+
// Exclude health check requests from tracing
72+
tracing.Filter = context =>
73+
!context.Request.Path.StartsWithSegments(HealthEndpointPath)
74+
&& !context.Request.Path.StartsWithSegments(AlivenessEndpointPath)
75+
)
6876
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
6977
//.AddGrpcClientInstrumentation()
7078
.AddHttpClientInstrumentation()
@@ -111,10 +119,10 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
111119
if (app.Environment.IsDevelopment())
112120
{
113121
// All health checks must pass for app to be considered ready to accept traffic after starting
114-
app.MapHealthChecks("/health");
122+
app.MapHealthChecks(HealthEndpointPath);
115123

116124
// Only health checks tagged with the "live" tag must pass for app to be considered alive
117-
app.MapHealthChecks("/alive", new HealthCheckOptions
125+
app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions
118126
{
119127
Predicate = r => r.Tags.Contains("live")
120128
});

src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData-CSharp.Web/Services/Ingestion/DataIngestor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ public async Task IngestDataAsync(IIngestionSource source)
3131
var deletedDocuments = await source.GetDeletedDocumentsAsync(documentsForSource);
3232
foreach (var deletedDocument in deletedDocuments)
3333
{
34-
logger.LogInformation("Removing ingested data for {documentId}", deletedDocument.DocumentId);
34+
logger.LogInformation("Removing ingested data for {DocumentId}", deletedDocument.DocumentId);
3535
await DeleteChunksForDocumentAsync(deletedDocument);
3636
await documentsCollection.DeleteAsync(deletedDocument.Key);
3737
}
3838

3939
var modifiedDocuments = await source.GetNewOrModifiedDocumentsAsync(documentsForSource);
4040
foreach (var modifiedDocument in modifiedDocuments)
4141
{
42-
logger.LogInformation("Processing {documentId}", modifiedDocument.DocumentId);
42+
logger.LogInformation("Processing {DocumentId}", modifiedDocument.DocumentId);
4343
await DeleteChunksForDocumentAsync(modifiedDocument);
4444

4545
await documentsCollection.UpsertAsync(modifiedDocument);
@@ -54,7 +54,7 @@ async Task DeleteChunksForDocumentAsync(IngestedDocument document)
5454
{
5555
var documentId = document.DocumentId;
5656
var chunksToDelete = await chunksCollection.GetAsync(record => record.DocumentId == documentId, int.MaxValue).ToListAsync();
57-
if (chunksToDelete.Any())
57+
if (chunksToDelete.Count != 0)
5858
{
5959
await chunksCollection.DeleteAsync(chunksToDelete.Select(r => r.Key));
6060
}

src/ProjectTemplates/Microsoft.Extensions.AI.Templates/src/ChatWithCustomData/README.Aspire.md

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -84,38 +84,8 @@ Note: Ollama and Docker are excellent open source products, but are not maintain
8484
#### ---#if (IsAzureOpenAI || UseAzureAISearch)
8585
## Using Azure Provisioning
8686

87-
The project is set up to automatically provision Azure resources, but local configuration is configured. For detailed instructions, see the [Local Provisioning documentation](https://learn.microsoft.com/dotnet/aspire/azure/local-provisioning#configuration).
87+
The project is set up to automatically provision Azure resources. When running the app for the first time, you will be prompted to provide Azure configuration values. For detailed instructions, see the [Local Provisioning documentation](https://learn.microsoft.com/dotnet/aspire/azure/local-provisioning#configuration).
8888

89-
#### ---#if (hostIdentifier == "vs")
90-
Configure local provisioning for this project using .NET User Secrets:
91-
92-
1. In Visual Studio, right-click on the ChatWithCustomData-CSharp.AppHost project in the Solution Explorer and select "Manage User Secrets".
93-
2. This opens a `secrets.json` file where you can store your API keys without them being tracked in source control. Add the following configuration:
94-
95-
```json
96-
{
97-
"Azure": {
98-
"SubscriptionId": "<Your subscription id>",
99-
"AllowResourceGroupCreation": true,
100-
"ResourceGroup": "<Valid resource group name>",
101-
"Location": "<Valid Azure location>"
102-
}
103-
}
104-
```
105-
106-
#### ---#else
107-
From the command line, configure local provisioning for this project using .NET User Secrets by running the following commands:
108-
109-
```sh
110-
cd ChatWithCustomData-CSharp.AppHost
111-
dotnet user-secrets set Azure:SubscriptionId "<Your subscription id>"
112-
dotnet user-secrets set Azure:AllowResourceGroupCreation "true"
113-
dotnet user-secrets set Azure:ResourceGroup "<Valid resource group name>"
114-
dotnet user-secrets set Azure:Location "<Valid Azure location>"
115-
```
116-
#### ---#endif
117-
118-
Make sure to replace placeholder values with real configuration values.
11989
#### ---#endif
12090
#### ---#if (UseQdrant)
12191

@@ -143,9 +113,9 @@ Note: Qdrant and Docker are excellent open source products, but are not maintain
143113

144114
## Trust the localhost certificate
145115

146-
Several .NET Aspire templates include ASP.NET Core projects that are configured to use HTTPS by default. If this is the first time you're running the project, an exception might occur when loading the Aspire dashboard. This error can be resolved by trusting the self-signed development certificate with the .NET CLI.
116+
Several Aspire templates include ASP.NET Core projects that are configured to use HTTPS by default. If this is the first time you're running the project, an exception might occur when loading the Aspire dashboard. This error can be resolved by trusting the self-signed development certificate with the .NET CLI.
147117

148-
See [Troubleshoot untrusted localhost certificate in .NET Aspire](https://learn.microsoft.com/dotnet/aspire/troubleshooting/untrusted-localhost-certificate) for more information.
118+
See [Troubleshoot untrusted localhost certificate in Aspire](https://learn.microsoft.com/dotnet/aspire/troubleshooting/untrusted-localhost-certificate) for more information.
149119

150120
# Updating JavaScript dependencies
151121

test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/aichatweb.AzureOpenAI_Qdrant_Aspire.verified/aichatweb/README.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,8 @@ This incompatibility can be addressed by upgrading to Docker Desktop 4.41.1. See
1717

1818
## Using Azure Provisioning
1919

20-
The project is set up to automatically provision Azure resources, but local configuration is configured. For detailed instructions, see the [Local Provisioning documentation](https://learn.microsoft.com/dotnet/aspire/azure/local-provisioning#configuration).
20+
The project is set up to automatically provision Azure resources. When running the app for the first time, you will be prompted to provide Azure configuration values. For detailed instructions, see the [Local Provisioning documentation](https://learn.microsoft.com/dotnet/aspire/azure/local-provisioning#configuration).
2121

22-
From the command line, configure local provisioning for this project using .NET User Secrets by running the following commands:
23-
24-
```sh
25-
cd aichatweb.AppHost
26-
dotnet user-secrets set Azure:SubscriptionId "<Your subscription id>"
27-
dotnet user-secrets set Azure:AllowResourceGroupCreation "true"
28-
dotnet user-secrets set Azure:ResourceGroup "<Valid resource group name>"
29-
dotnet user-secrets set Azure:Location "<Valid Azure location>"
30-
```
31-
32-
Make sure to replace placeholder values with real configuration values.
3322

3423
# Running the application
3524

@@ -47,9 +36,9 @@ Make sure to replace placeholder values with real configuration values.
4736

4837
## Trust the localhost certificate
4938

50-
Several .NET Aspire templates include ASP.NET Core projects that are configured to use HTTPS by default. If this is the first time you're running the project, an exception might occur when loading the Aspire dashboard. This error can be resolved by trusting the self-signed development certificate with the .NET CLI.
39+
Several Aspire templates include ASP.NET Core projects that are configured to use HTTPS by default. If this is the first time you're running the project, an exception might occur when loading the Aspire dashboard. This error can be resolved by trusting the self-signed development certificate with the .NET CLI.
5140

52-
See [Troubleshoot untrusted localhost certificate in .NET Aspire](https://learn.microsoft.com/dotnet/aspire/troubleshooting/untrusted-localhost-certificate) for more information.
41+
See [Troubleshoot untrusted localhost certificate in Aspire](https://learn.microsoft.com/dotnet/aspire/troubleshooting/untrusted-localhost-certificate) for more information.
5342

5443
# Updating JavaScript dependencies
5544

0 commit comments

Comments
 (0)