Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,42 @@ I envision something like this:

## Development

The repo now runs directly on your host machine; no devcontainers are required. A typical setup looks like this:
There are two ways to run the development environment: using .NET Aspire (recommended) or the traditional manual setup. Both use the same prerequisites - no Docker required.

### Option 1: Using .NET Aspire (Recommended)

.NET Aspire provides a streamlined development experience with automatic orchestration of all services and a unified monitoring dashboard.

**Prerequisites:**
- .NET 10 SDK
- PowerShell 7.4+
- Azure Functions Core Tools v4
- VS Code with the Azurite extension (`azurite.azurite`)

**Getting Started:**

1. Clone the repository and run the code generators and bootstrap script:
```powershell
./bootstrap.ps1
```

2. Start the Azurite Table service via the VS Code Azurite extension (`Az: Start Table Service` from the Command Palette).

3. Start all services with a single command:
```powershell
dotnet run --project explainpowershell.apphost
```

4. Open the Aspire dashboard (URL shown in console output) to monitor all services, view logs, and access the frontend.

The Aspire AppHost automatically:
- Launches the Azure Functions backend (analysis service)
- Starts the Blazor WebAssembly frontend
- Provides a unified dashboard for monitoring and debugging

### Option 2: Traditional Manual Setup

If you prefer not to use Aspire, you can still run the repo directly on your host machine:

1. Install prerequisites: the latest .NET SDK (currently 10.x), Azure Functions Core Tools v4, PowerShell 7.4+, and the VS Code extensions recommended in `.vscode/extensions.json` (notably the Azurite extension `azurite.azurite`).
2. Clone the repository and open it in VS Code. Run `./bootstrap.ps1` from the repo root once to install PowerShell modules, restore dependencies, seed the Azurite table storage, and run the backend tests. The Azure Function backend now runs as a .NET 10 isolated worker, so make sure the `FUNCTIONS_WORKER_RUNTIME` remains `dotnet-isolated` in `local.settings.json`.
Expand Down
18 changes: 18 additions & 0 deletions explainpowershell.apphost/AppHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var builder = DistributedApplication.CreateBuilder(args);

// Use the VS Code Azurite extension (no Docker required)
// Start Azurite via VS Code Command Palette: "Azurite: Start Table Service"
// Connection string matches the default Azurite development storage settings
var storage = builder.AddConnectionString("AzureWebJobsStorage");

// Add the Azure Functions analysis service backend
var analysisService = builder.AddAzureFunctionsProject<Projects.explainpowershell>("analysisservice")
.WithReference(storage);

// Add the Blazor WebAssembly frontend as a static web app
// Note: Blazor WASM runs in the browser - the appsettings.json configures the BaseAddress
// to point to the analysis service at http://localhost:7071/api/
builder.AddProject<Projects.explainpowershell_frontend>("frontend")
.WithExternalHttpEndpoints();

builder.Build().Run();
31 changes: 31 additions & 0 deletions explainpowershell.apphost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17269;http://localhost:15100",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21042",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23140",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22004"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15100",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19069",
"ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18210",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20141"
}
}
}
}
11 changes: 11 additions & 0 deletions explainpowershell.apphost/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true"
}
}
9 changes: 9 additions & 0 deletions explainpowershell.apphost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
20 changes: 20 additions & 0 deletions explainpowershell.apphost/explainpowershell.apphost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Aspire.AppHost.Sdk/13.0.1">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>a821ac25-3c11-4be4-9c85-e1a4f69591e5</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.Azure.Functions" Version="13.0.1-preview.1.25575.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\explainpowershell.analysisservice\explainpowershell.csproj" />
<ProjectReference Include="..\explainpowershell.frontend\explainpowershell.frontend.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion explainpowershell.frontend/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"dotnetRunMessages": "true"
"dotnetRunMessages": true
},
"WSL": {
"commandName": "WSL2",
Expand Down
127 changes: 127 additions & 0 deletions explainpowershell.servicedefaults/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.ServiceDiscovery;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;

namespace Microsoft.Extensions.Hosting;

// Adds common Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
// This project should be referenced by each service project in your solution.
// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
public static class Extensions
{
private const string HealthEndpointPath = "/health";
private const string AlivenessEndpointPath = "/alive";

public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.ConfigureOpenTelemetry();

builder.AddDefaultHealthChecks();

builder.Services.AddServiceDiscovery();

builder.Services.ConfigureHttpClientDefaults(http =>
{
// Turn on resilience by default
http.AddStandardResilienceHandler();

// Turn on service discovery by default
http.AddServiceDiscovery();
});

// Uncomment the following to restrict the allowed schemes for service discovery.
// builder.Services.Configure<ServiceDiscoveryOptions>(options =>
// {
// options.AllowedSchemes = ["https"];
// });

return builder;
}

public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.Logging.AddOpenTelemetry(logging =>
{
logging.IncludeFormattedMessage = true;
logging.IncludeScopes = true;
});

builder.Services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddRuntimeInstrumentation();
})
.WithTracing(tracing =>
{
tracing.AddSource(builder.Environment.ApplicationName)
.AddAspNetCoreInstrumentation(tracing =>
// Exclude health check requests from tracing
tracing.Filter = context =>
!context.Request.Path.StartsWithSegments(HealthEndpointPath)
&& !context.Request.Path.StartsWithSegments(AlivenessEndpointPath)
)
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
//.AddGrpcClientInstrumentation()
.AddHttpClientInstrumentation();
});

builder.AddOpenTelemetryExporters();

return builder;
}

private static TBuilder AddOpenTelemetryExporters<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);

if (useOtlpExporter)
{
builder.Services.AddOpenTelemetry().UseOtlpExporter();
}

// Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
//if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
//{
// builder.Services.AddOpenTelemetry()
// .UseAzureMonitor();
//}

return builder;
}

public static TBuilder AddDefaultHealthChecks<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.Services.AddHealthChecks()
// Add a default liveness check to ensure app is responsive
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);

return builder;
}

public static WebApplication MapDefaultEndpoints(this WebApplication app)
{
// Adding health checks endpoints to applications in non-development environments has security implications.
// See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
if (app.Environment.IsDevelopment())
{
// All health checks must pass for app to be considered ready to accept traffic after starting
app.MapHealthChecks(HealthEndpointPath);

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

return app;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireSharedProject>true</IsAspireSharedProject>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="10.0.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.13.1" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.13.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.13.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.13.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.13.0" />
</ItemGroup>

</Project>
Loading