data-api-builder
Azure · Azure/data-api-builder
Provides a no-code tool to create secure REST and GraphQL endpoints for various Azure and on-prem databases, supporting MCP.
Data API builder provides modern REST, GraphQL endpoints and MCP tools to your Azure Databases and on-prem stores.
Preview
What you can do with it
- Quickly expose a SQL database via a GraphQL API for a web app.
- Build a backend for a mobile application without writing API code.
- Integrate legacy on-prem databases with modern cloud-native applications.
Safety check
No risky patterns found in the files we scanned.
Automated scan of the repo files. Always review code you run.
From the README
Data API builder for Azure Databases
Join the community
Want to be part of our priorities and roadmap? Sign up here.
About Data API builder
Data API builder (DAB) is an open-source, no-code tool that creates secure, full-featured REST and GraphQL endpoints for your database. It’s a CRUD data API engine that runs in a container—on Azure, any other cloud, or on-premises. DAB is built for developers with integrated tooling, telemetry, and other productivity features.
[!IMPORTANT] Data API builder (DAB) is open source and always free.
Which databases does Data API builder support?
| Azure SQL | SQL Server | SQLDW | Cosmos DB | PostgreSQL | MySQL | |
|---|---|---|---|---|---|---|
| Supported | Yes | Yes | Yes | Yes | Yes | Yes |
Which environments does Data API builder support?
| On-Prem | Azure | AWS | GCP | Other | |
|---|---|---|---|---|---|
| Supported | Yes | Yes | Yes | Yes | Yes |
Which endpoints does Data API builder support?
| REST | GraphQL | MCP | |
|---|---|---|---|
| Supported | Yes | Yes | Yes |
Getting started
Use the Getting Started tutorial to quickly explore the core tools and concepts.
1. Install the dotnet command line
[!NOTE] You may already have .NET installed!
The Data API builder (DAB) command line requires the .NET runtime version 8 or later.
Validate your installation
dotnet --version
2. Install the dab command line
The Data API builder (DAB) command line is cross-platform and intended for local developer use.
dotnet tool install microsoft.dataapibuilder -g
Validate your installation
dab --version
3. Create your database (example: Azure SQL database / T-SQL)
This example uses a single table for simplicity.
CREATE TABLE dbo.Todo
(
Id INT PRIMARY KEY IDENTITY,
Title NVARCHAR(500) NOT NULL,
IsCompleted BIT NOT NULL DEFAULT 0
);
INSERT dbo.Todo (Title, IsCompleted)
VALUES
('Walk the dog', 0),
('Feed the fish', 0),
('Clean the cat', 1);
4. Prepare your connection string
Data API builder (DAB) supports .env files for testing process-level environment variables.
PowerShell (Windows)
echo "my-connection-string=$env:database_connection_string" > .env
cmd.exe (Windows)
echo my-connection-string=%database_connection_string% > .env
bash (macOS/Linux)
echo "my-connection-string=$database_connection_string" > .env
Resulting .env file
The file .env is automatically created through this process. These are the resulting contents:
"my-connection-string=$env:database_connection_string"
[!NOTE] Be sure and replace
database_connection_stringwith your actual database connection string.
[!IMPORTANT] Adding
.envto your.gitignorefile will help ensure your secrets are not added to source control.
5. Create your initial configuration file
Data API builder (DAB) requires a JSON configuration file. Use dab --help for syntax options.
dab init
--database-type mssql
--connection-string "@env('my-connection-string')"
--host-mode development
[!NOTE] Including
--host-mode developmentenables Swagger for REST and Nitro for GraphQL.
Resulting configuration
The file dab-config.json is automatically created through this process. These are the resulting contents:
{
"$schema": "https://github.com/Azure/data-api-builder/releases/download/v1.5.56/dab.draft.schema.json",
"data-source": {
"database-type": "mssql",
"connection-string": "@env('my-connection-string')",
"options": {
"set-session-context": false
}
},
"runtime": {
"rest": {
"enabled": true,
"path": "/api",
"request-body-strict": true
},
"graphql": {
"enabled": true,
"path": "/graphql",
"allow-introspection": true
},
"host": {
"cors": {
"origins": [],
"allow-credentials": false
},
"authentication": {
"provider": "AppService"
},
"mode": "development"
}
},
"entities": { }
}
6. Add your table to the configuration
dab add Todo
--source "dbo.Todo"
--permissions "anonymous:*"
[!NOTE] DAB supports tables, views, and stored procedures. When the type is not specified, the default is
table.
Resulting configuration
The entities section of the configuration is no longer empty:
{
"entities": {
"Todo": {
"source": {
"object": "dbo.Todo",
"type": "table"
},
"graphql": {
"enabled": true,
"type": {
"singular": "Todo",
"plural": "Todos"
}
},
"rest": {
"enabled": true
},
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "*"
}
]
}
]
}
}
}
7. Run Data API builder
In production, DAB runs in a container. In development, it’s locally self-hosted.
dab start
[!IMPORTANT] The DAB CLI assumes your configuration file is called
dab-config.jsonand is in the local folder.
8. Access your data!
By default, DAB enables both REST and GraphQL.
GET http://localhost:5000/api/Todo
[!NOTE] Change the URL to match your port if it is different.