com um clique
aspire-data-api-builder
Guide for .NET Aspire orchestration of SQL Server + Data API Builder + SQL Commander + MCP Inspector. Use when asked to create an Aspire-based DAB environment.
Menu
Guide for .NET Aspire orchestration of SQL Server + Data API Builder + SQL Commander + MCP Inspector. Use when asked to create an Aspire-based DAB environment.
Add MCP Inspector to a .NET Aspire AppHost for debugging MCP servers like Data API Builder. Use when asked to inspect MCP traffic, debug MCP connections, or add MCP Inspector to Aspire.
Deploy Data API Builder to Azure Container Apps with Azure SQL, ACR, and azd. Use when asked to deploy DAB to Azure, create Bicep for DAB, or set up cloud API hosting.
Deploy MCP Inspector to Azure Container Apps with nginx reverse proxy for same-origin routing. Use when asked to deploy Inspector to Azure, containerize Inspector, or preconfigure Inspector UI for cloud.
Guide for creating and auditing GitHub Copilot Agent Skills. Use this when asked to create new skills, understand skill structure, or improve existing skills.
Data API Builder CLI commands for init, add, update, export, and start. Use when asked to create a dab-config, add entities, configure REST/GraphQL endpoints, or run DAB locally via CLI.
Data API Builder dab-config.json structure, entities, relationships, permissions, and runtime settings. Use when asked to create, edit, validate, or troubleshoot a dab-config.json file.
| name | aspire-data-api-builder |
| description | Guide for .NET Aspire orchestration of SQL Server + Data API Builder + SQL Commander + MCP Inspector. Use when asked to create an Aspire-based DAB environment. |
This skill provides a minimal workflow for running SQL Server, Data API Builder (DAB), SQL Commander, and MCP Inspector using .NET Aspire's single-file AppHost pattern for local development.
apphost.cs file orchestrates everything — no project files, no Docker Composeaspire run starts all services with health checks, dependencies, and telemetrydab-config.json read-only.WaitFor() and health checkshttp://localhost:15888dotnet --versiondotnet tool install -g aspire — verify: aspire --versiondab-config.json in workspace root using @env('MSSQL_CONNECTION_STRING')MVP rule: Only add database schema/seed scripts if user explicitly asks.
.env with connection string (gitignored).apphost.cs using the template below.aspire run..env (example)# Never commit this file
SA_PASSWORD=YourStrong@Passw0rd
MSSQL_CONNECTION_STRING=Server=sql-server;Database=MyDb;User Id=sa;Password=YourStrong@Passw0rd;TrustServerCertificate=true
Critical: Add
.env,**\bin, and**\objto.gitignorebefore creating secrets.
apphost.cs (minimal template)// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#:sdk Aspire.AppHost.Sdk@13.0.0
#:package Aspire.Hosting.SqlServer@13.0.0
#:package CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects@9.8.1-beta.420
#:package CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder@9.8.1-beta.420
#:package CommunityToolkit.Aspire.Hosting.McpInspector@9.8.0
var builder = DistributedApplication.CreateBuilder(args);
var options = new
{
SqlDatabase = "MyDb",
DabConfig = "dab-config.json",
DabImage = "1.7.83-rc",
SqlCmdrImage = "latest"
};
var sqlServer = builder
.AddSqlServer("sql-server")
.WithDataVolume("sql-data")
.WithEnvironment("ACCEPT_EULA", "Y")
.WithLifetime(ContainerLifetime.Persistent);
var sqlDatabase = sqlServer
.AddDatabase(options.SqlDatabase);
var dabServer = builder
.AddContainer("data-api", image: "azure-databases/data-api-builder", tag: options.DabImage)
.WithImageRegistry("mcr.microsoft.com")
.WithBindMount(source: new FileInfo(options.DabConfig).FullName, target: "/App/dab-config.json", isReadOnly: true)
.WithHttpEndpoint(targetPort: 5000, name: "http")
.WithEnvironment("MSSQL_CONNECTION_STRING", sqlDatabase)
.WithUrls(context =>
{
context.Urls.Clear();
context.Urls.Add(new() { Url = "/graphql", DisplayText = "GraphQL", Endpoint = context.GetEndpoint("http") });
context.Urls.Add(new() { Url = "/swagger", DisplayText = "Swagger", Endpoint = context.GetEndpoint("http") });
context.Urls.Add(new() { Url = "/health", DisplayText = "Health", Endpoint = context.GetEndpoint("http") });
})
.WithOtlpExporter()
.WithParentRelationship(sqlDatabase)
.WithHttpHealthCheck("/health")
.WaitFor(sqlDatabase);
var sqlCommander = builder
.AddContainer("sql-cmdr", "jerrynixon/sql-commander", options.SqlCmdrImage)
.WithImageRegistry("docker.io")
.WithHttpEndpoint(targetPort: 8080, name: "http")
.WithEnvironment("ConnectionStrings__db", sqlDatabase)
.WithUrls(context =>
{
context.Urls.Clear();
context.Urls.Add(new() { Url = "/", DisplayText = "Commander", Endpoint = context.GetEndpoint("http") });
})
.WithParentRelationship(sqlDatabase)
.WithHttpHealthCheck("/health")
.WaitFor(sqlDatabase);
var mcpInspector = builder
.AddMcpInspector("mcp-inspector")
.WithMcpServer(dabServer)
.WithParentRelationship(dabServer)
.WithEnvironment("NODE_TLS_REJECT_UNAUTHORIZED", "0")
.WaitFor(dabServer)
.WithUrls(context =>
{
context.Urls.First().DisplayText = "Inspector";
});
await builder.Build().RunAsync();
dab-config.json (minimal){
"$schema": "https://dataapibuilder.azureedge.net/schemas/latest/dab.draft.schema.json",
"data-source": {
"database-type": "mssql",
"connection-string": "@env('MSSQL_CONNECTION_STRING')"
},
"runtime": {
"rest": {
"enabled": true,
"path": "/api"
},
"graphql": {
"enabled": true,
"path": "/graphql"
},
"host": {
"mode": "development",
"cors": {
"origins": ["*"],
"allow-credentials": false
}
},
"mcp": {
"enabled": true
}
},
"entities": {}
}
aspire run
This command:
Aspire Dashboard: http://localhost:15888
| Service | URL | Purpose |
|---|---|---|
| Aspire Dashboard | http://localhost:15888 | Monitor all services, logs, metrics |
| DAB GraphQL | Click "GraphQL" link in dashboard | Query data via GraphQL |
| DAB Swagger | Click "Swagger" link in dashboard | REST API documentation |
| DAB Health | Click "Health" link in dashboard | Service health status |
| SQL Commander | Click "Commander" link in dashboard | SQL query tool |
| MCP Inspector | Click "Inspector" link in dashboard | Test MCP endpoints |
Note: Aspire assigns dynamic ports. Use dashboard links instead of hardcoded URLs.
Press Ctrl+C in terminal where aspire run is active, or:
docker stop $(docker ps -q)
To deploy a SQL schema on startup, add this before var dabServer:
var sqlDatabaseWithSchema = sqlDatabase
.WithSqlProject(new FileInfo("database.sql").FullName);
Then change dabServer to wait for sqlDatabaseWithSchema instead of sqlDatabase:
.WaitFor(sqlDatabaseWithSchema);
aspire: command not foundFix:
dotnet tool install -g aspire
Check Docker:
docker ps -a
docker logs <container-id>
Verify connection string in .env uses service name sql-server, not localhost:
MSSQL_CONNECTION_STRING=Server=sql-server;Database=MyDb;...
Aspire auto-assigns ports. If dashboard doesn't open, check terminal output for actual URL.
| Feature | Aspire | Docker Compose |
|---|---|---|
| Definition | Single C# file | YAML file |
| Language | C# | YAML |
| Dependencies | .WaitFor() + health checks | depends_on + healthcheck |
| Monitoring | Built-in dashboard with logs, metrics, traces | External tools required |
| Service Discovery | Automatic | Manual with service names |
| Hot Reload | Yes with --watch | No |
| Debugging | Native .NET debugging | Container debugging only |
Use Aspire when:
Use Docker Compose when:
Containers reference each other by service name:
sql-serverdata-apisql-cmdrmcp-inspectorSQL Server data persists in Docker volume sql-data:
docker volume ls | Select-String sql-data
To reset database:
aspire run # Stop with Ctrl+C
docker volume rm <volume-name>
aspire run # Restart
GET /health (must return 200)GET /healthServices won't start until dependencies are healthy.
For Azure deployment, see the
azure-data-api-builderskill.