Aspire Troubleshooting¶
Common Aspire issues and solutions for Forge projects.
๐ Overview¶
This guide covers common issues you may encounter when working with Aspire in Forge projects and how to resolve them.
๐ Startup Issues¶
SDK Not Found¶
Symptom:
Solution: Ensure your AppHost project uses the correct SDK format:
And run a restore:
Version Mismatch¶
Symptom:
Solution: Update all Aspire packages to match:
<ItemGroup>
<PackageReference Include="Aspire.Hosting" Version="13.1.0" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.1.0" />
</ItemGroup>
Port Already in Use¶
Symptom:
Solution:
# Find and kill process
Get-NetTCPConnection -LocalPort 5000 |
Select-Object -ExpandProperty OwningProcess |
ForEach-Object { Stop-Process -Id $_ -Force }
Or change port in launchSettings.json:
๐ฆ Resource Issues¶
Container Won't Start¶
Symptom: Container resource stays in "Starting" state
Checks:
- Docker is running
- Image exists or can be pulled
- Port isn't in use
- Sufficient resources
# Verify Docker
docker info
# Pull image manually
docker pull mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
# Check container logs
docker logs <container-name>
Database Connection Failed¶
Symptom:
Solution: Ensure connection string uses Aspire's service discovery:
// Correct - uses Aspire reference
builder.AddProject<Projects.MyApi>("api")
.WithReference(database);
// In API - gets connection from configuration
var conn = builder.Configuration.GetConnectionString("database");
Resource Reference Not Found¶
Symptom:
Solution: Ensure resource is created before reference:
// Create resource first
var database = builder.AddSqlServer("sql")
.AddDatabase("mydb");
// Then reference it
builder.AddProject<Projects.MyApi>("api")
.WithReference(database);
๐ Service Discovery Issues¶
Service Not Found¶
Symptom:
Checks:
- Resource name matches reference name
- Resource is actually running
- Using correct endpoint name
// Correct naming
var api = builder.AddProject<Projects.MyApi>("my-api");
// Consuming service references by name
builder.AddProject<Projects.MyFrontend>("frontend")
.WithReference(api);
Endpoint Not Available¶
Symptom: Service is running but can't be reached
Solution: Check endpoint configuration:
// Expose endpoint explicitly
builder.AddProject<Projects.MyApi>("api")
.WithHttpsEndpoint(port: 5001, name: "https");
๐ฅ๏ธ Dashboard Issues¶
Dashboard Won't Open¶
Symptom: Browser shows error or blank page
Checks:
- Aspire is fully started
- Dashboard URL is correct (usually https://localhost:15888)
- No browser extensions blocking
Dashboard Shows No Resources¶
Symptom: Dashboard loads but resources list is empty
Checks:
- AppHost is running (not just API)
- Resources are registered in Program.cs
- Check for startup errors
๐งช Integration Test Issues¶
Tests Can't Find Services¶
Symptom:
Solution: Use Aspire test fixtures:
public class IntegrationTests : IClassFixture<AspireAppFixture>
{
private readonly AspireAppFixture _fixture;
public IntegrationTests(AspireAppFixture fixture)
{
_fixture = fixture;
}
[Fact]
public async Task Test()
{
var client = _fixture.CreateClient("api");
// ...
}
}
Resource Not Ready in Time¶
Symptom: Tests fail with connection errors intermittently
Solution: Add health check waits:
builder.AddProject<Projects.MyApi>("api")
.WithHealthCheck("api-health");
// In test
await _fixture.WaitForResourceAsync("api", TimeSpan.FromSeconds(30));
โ Common Patterns¶
Correct Resource Setup¶
var builder = DistributedApplication.CreateBuilder(args);
// Infrastructure resources
var sql = builder.AddSqlServer("sql")
.AddDatabase("mydb");
var cosmos = builder.AddAzureCosmosDB("cosmos")
.AddDatabase("data");
// Application with references
var api = builder.AddProject<Projects.MyApi>("api")
.WithReference(sql)
.WithReference(cosmos);
var frontend = builder.AddProject<Projects.MyFrontend>("frontend")
.WithReference(api);
builder.Build().Run();
Debug Logging¶
Enable detailed Aspire logging:
โก Quick Fixes¶
| Issue | Quick Fix |
|---|---|
| Port in use | Change port or kill process |
| Container stuck | Restart Docker |
| Package mismatch | Update all to same version |
| Service not found | Check resource name spelling |
| Dashboard blank | Clear browser cache |
| Tests timeout | Increase wait timeout |