NET Aspire isn’t limited to .NET services. You can orchestrate a Python service (FastAPI on Uvicorn) right alongside your .NET components—same lifecycle, unified logs, single dotnet run.
Below is a minimal setup that boots a FastAPI app with health endpoint, exposes it via Aspire, and keeps everything tidy in one solution.
Folder layout
04_PythonUvicorn/
├─ AppHost.cs
├─ PythonUvicorn.csproj
├─ appsettings.json
├─ appsettings.Development.json
├─ README.md
└─ uvicornapp-api/ # Python app lives here
├─ main.py
├─ requirements.txt
└─ (optional) .venv/
AppHost.cs (Aspire)
var builder = DistributedApplication.CreateBuilder(args);
var uvicorn = builder.AddUvicornApp(
name: "uvicornapp",
projectDirectory: "./uvicornapp-api",
appName: "main:app"
)
.WithHttpEndpoint(targetPort: 8000) // app listens on 8000
.WithExternalHttpEndpoints(); // optional, expose to host
builder. Build().Run();
Continue reading “Running a Python FastAPI (Uvicorn) service from .NET Aspire”
