Skip to content

Commit bffaa7d

Browse files
committed
chore: update package versions and improve Redis cache configuration
1 parent 9a9c0b0 commit bffaa7d

File tree

7 files changed

+468
-440
lines changed

7 files changed

+468
-440
lines changed

AppHost/AppHost.cs

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,42 @@
77

88
// Add Redis cache
99
var redis = builder.AddRedis("redis")
10-
.WithRedisInsight()
10+
.WithRedisInsight(config => {
11+
config.WithLifetime(ContainerLifetime.Persistent);
12+
config.WithHostPort(8001); // Default port for RedisInsight
13+
})
1114
.WithLifetime(ContainerLifetime.Persistent)
1215
.PublishAsConnectionString();
1316

1417
// NOTE: The type returned by AddAzureStorage is IResourceBuilder<AzureStorageResource>,
1518
// but if storage is being cast or wrapped, ensure it is of the correct type for extension methods.
1619
var storage = builder.AddAzureStorage("azure-storage")
17-
.RunAsEmulator(options =>
18-
{
19-
// Configure the Azure Storage Emulator options here if needed
20-
options.WithLifetime(ContainerLifetime.Persistent);
21-
options.WithTablePort(27002);
22-
options.WithBlobPort(27001);
23-
options.WithQueuePort(27003);
24-
});
20+
.RunAsEmulator(options =>
21+
{
22+
// Configure the Azure Storage Emulator options here if needed
23+
options.WithLifetime(ContainerLifetime.Persistent);
24+
options.WithDataVolume("copilotthatjawn-storage");
25+
options.WithTablePort(27002);
26+
options.WithBlobPort(27001);
27+
options.WithQueuePort(27003);
28+
});
2529

2630
var tables = storage.AddTables("tables");
2731
var blobs = storage.AddBlobs("blobs");
2832

2933
var web = builder.AddProject<Web>("web")
30-
.WithReference(tables)
31-
.WithReference(blobs)
32-
.WithReference(redis)
33-
.WaitFor(tables)
34-
.WaitFor(redis)
35-
.WithExternalHttpEndpoints();
34+
.WithReference(tables)
35+
.WithReference(blobs)
36+
.WithReference(redis)
37+
.WaitFor(tables)
38+
.WaitFor(redis)
39+
.WithExternalHttpEndpoints()
40+
.WithHttpCommand("/api/cache/refresh", "Refresh Cache",
41+
commandName: "refresh-cache",
42+
commandOptions: new HttpCommandOptions
43+
{
44+
Method = HttpMethod.Post,
45+
IconName = "Recycle"
46+
});
3647

3748
builder.Build().Run();

AppHost/AppHost.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<Sdk Name="Aspire.AppHost.Sdk" Version="9.3.0" />
3+
<Sdk Name="Aspire.AppHost.Sdk" Version="9.5.1" />
44

55
<PropertyGroup>
66
<OutputType>Exe</OutputType>
@@ -10,10 +10,10 @@
1010
<UserSecretsId>21fabb30-ac7d-4818-8766-92672e7b369a</UserSecretsId>
1111
</PropertyGroup>
1212
<ItemGroup>
13-
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.3.0" />
14-
<PackageReference Include="Aspire.Hosting.Azure.AppContainers" Version="9.3.0" />
15-
<PackageReference Include="Aspire.Hosting.Azure.Storage" Version="9.3.0" />
16-
<PackageReference Include="Aspire.Hosting.Redis" Version="9.3.0" />
13+
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.5.1" />
14+
<PackageReference Include="Aspire.Hosting.Azure.AppContainers" Version="9.5.1" />
15+
<PackageReference Include="Aspire.Hosting.Azure.Storage" Version="9.5.1" />
16+
<PackageReference Include="Aspire.Hosting.Redis" Version="9.5.1" />
1717
</ItemGroup>
1818

1919
<ItemGroup>

NuGet.config

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear />
5+
<add key="https://api.nuget.org/v3/index.json" value="https://api.nuget.org/v3/index.json" />
6+
</packageSources>
7+
<packageSourceMapping>
8+
<packageSource key="https://api.nuget.org/v3/index.json">
9+
<package pattern="*" />
10+
</packageSource>
11+
</packageSourceMapping>
12+
</configuration>

ServiceDefaults/ServiceDefaults.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1212

1313
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.4.0" />
14-
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.3.0" />
14+
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.5.1" />
1515
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.12.0" />
1616
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0" />
1717
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.0" />

Web/Extensions/EndpointExtensions.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,17 +221,17 @@ public static void MapCacheRefreshEndpoint(this WebApplication app)
221221
return Results.Problem("API key not configured", statusCode: 500);
222222
}
223223

224-
// Only perform cache refresh in non-development environments
225-
if (environment.IsDevelopment())
226-
{
227-
logger.LogInformation("Development environment detected. Skipping cache refresh.");
228-
return Results.Ok(new
229-
{
230-
message = "Cache refresh skipped in development environment",
231-
timestamp = DateTime.UtcNow,
232-
environment = "Development"
233-
});
234-
}
224+
// Allow cache refresh in all environments
225+
// if (environment.IsDevelopment())
226+
// {
227+
// logger.LogInformation("Development environment detected. Skipping cache refresh.");
228+
// return Results.Ok(new
229+
// {
230+
// message = "Cache refresh skipped in development environment",
231+
// timestamp = DateTime.UtcNow,
232+
// environment = "Development"
233+
// });
234+
// }
235235

236236
// Refresh content cache
237237
await contentService.RefreshContentAsync();

0 commit comments

Comments
 (0)