Lesson 1 of 5 Data API Builder

Data API Builder Configuration Files

This lesson explains what Data API builder does, the structure of its configuration file and the CLI commands that maintain it.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the data-source, runtime and entities sections.
  • Identify the DAB CLI commands and their purposes.
  • Explain how to keep secrets out of the configuration file.

What Data API builder does

Data API builder is a free, open-source engine that replaces most hand-written CRUD APIs. It reads a configuration file, connects to the database and serves endpoints for the tables, views and stored procedures listed as entities, with authentication, role-based authorization, pagination, filtering, caching and telemetry built in. It supports SQL Server, Azure SQL, SQL database in Fabric, Azure Cosmos DB, PostgreSQL and MySQL, and it runs anywhere as a stateless process or container. REST and GraphQL are served at the same time, and from version 1.7 the same entities are also available to AI agents through the SQL MCP Server endpoint.

The following diagram shows Data API builder serving database objects.

What Data API builder does. It reads dab-config.json, connects to the database and serves endpoints for the tables, views and stored procedures listed as entities, with authentication, role-based authorization, pagination, filtering, caching and telemetry built in. REST and GraphQL are served at the same time, and from version 1.7 the same entities are available to AI agents through the SQL MCP Server endpoint. It runs as a stateless process or container.
One configuration, three kinds of endpoint.
True or false

What DAB is

Exam skills 2.4.1

Decide whether each statement about Data API builder is true.

Log in to try this activity Interactive activities are free with an account.

Structure of dab-config.json

The configuration file has three main sections, as the following example shows. data-source describes the database; runtime configures the REST, GraphQL and MCP endpoints and the host; and entities lists the exposed objects.

{
  "$schema": "https://github.com/Azure/data-api-builder/releases/latest/download/dab.draft.schema.json",
  "data-source": {
    "database-type": "mssql",
    "connection-string": "@env('SQL_CONNECTION_STRING')",
    "options": { "set-session-context": true }
  },
  "runtime": {
    "rest":    { "enabled": true, "path": "/api" },
    "graphql": { "enabled": true, "path": "/graphql", "allow-introspection": true },
    "mcp":     { "enabled": true, "path": "/mcp" },
    "host": {
      "mode": "development",
      "cors": { "origins": ["https://app.contoso.com"] },
      "authentication": { "provider": "Simulator" }
    }
  },
  "entities": {
    "Product": {
      "source": { "object": "Catalog.Product", "type": "table" },
      "permissions": [ { "role": "anonymous", "actions": ["read"] } ]
    }
  }
}
Sort into groups

Which section?

Exam skills 2.4.1

Decide which section of dab-config.json holds each setting.

Log in to try this activity Interactive activities are free with an account.

The DAB CLI and secrets

The DAB CLI, installed as a .NET tool (dotnet tool install -g microsoft.dataapibuilder), creates and edits the file so its structure stays valid, as the following table shows.

CommandPurpose
dab initCreates the file with the database type, connection string and host options
dab addAdds an entity with its source, type and permissions
dab updateChanges an entity, for example adding relationships, fields or cache settings
dab configureChanges runtime and data source settings
dab validateChecks the file against the schema and the database
dab startRuns the engine locally

Connection strings and keys are never written into the file. @env('NAME') reads an environment variable (including from a local .env file), and @akv('name') reads an Azure Key Vault secret. With Microsoft Entra authentication, such as Authentication=Active Directory Default, the connection string contains no secret at all. Environment-specific files such as dab-config.Development.json override the base file when the DAB_ENVIRONMENT variable selects them.

Match the pairs

DAB CLI commands

Exam skills 2.4.1

Match each task with the DAB CLI command.

Log in to try this activity Interactive activities are free with an account.
Worked example

Starting a configuration safely

A developer must create a DAB configuration for an Azure SQL database that will be committed to Git and deployed to several environments with different databases. The connection must not appear in the repository. Which command starts the configuration?

Run dab init --database-type mssql --connection-string "@env('SQL_CONNECTION_STRING')" --host-mode development, then set SQL_CONNECTION_STRING per environment, ideally with Microsoft Entra authentication so it holds no password. The file can then be committed and reused everywhere. Putting the literal connection string in the file would commit it to Git, and maintaining one hand-edited file per environment duplicates every entity definition.

Check yourself

Which DAB syntax reads a secret from Azure Key Vault?

Show answer

@akv('secret-name'); @env('NAME') reads an environment variable.

Exam Tips

Remember for the exam

  • Create the file: dab init; add objects: dab add; check it: dab validate.
  • Three sections: data-source, runtime and entities.
  • Keep secrets out: @env() or @akv(), or a passwordless Entra connection string.
  • One configuration serves REST, GraphQL and MCP.