Edit

Share via


init command

Initialize a new Data API builder configuration file. The resulting JSON captures data source details, enabled endpoints (REST, GraphQL, MCP), authentication, and runtime behaviors.

Syntax

dab init [options]

If the target config file already exists, the command overwrites it. There's no merge. Use version control or backups if you need to preserve the previous file.

Quick glance

Option Summary
-c, --config Output config file name (default dab-config.json)

Authentication section

Option Summary
--auth.audience JSON Web Token (JWT) audience claim
--auth.issuer JSON Web Token (JWT) issuer claim
--auth.provider Identity provider (default Unauthenticated)

Data Source section

Option Summary
--connection-string Database connection string (supports @env())
--cosmosdb_nosql-container Cosmos DB NoSQL container name (optional)
--cosmosdb_nosql-database Cosmos DB NoSQL database name (required for cosmosdb_nosql)
--database-type Database type: mssql, mysql, postgresql, cosmosdb_postgresql, cosmosdb_nosql
--set-session-context Enable SQL Server session context (mssql only)

GraphQL section

Option Summary
--graphql.disabled Deprecated. Disables GraphQL (use --graphql.enabled false)
--graphql.enabled Enable GraphQL (default true)
--graphql.multiple-create.enabled Allow multiple create mutations (default false)
--graphql.path GraphQL endpoint prefix (default /graphql)
--graphql-schema Path to GraphQL schema (required for cosmosdb_nosql)

Host and authentication section

Option Summary
--host-mode Host mode: Development or Production (default Production)
--cors-origin Allowed origins list (comma-separated)
--runtime.base-route Global prefix for all endpoints

MCP section

Option Summary
--mcp.aggregate-records.query-timeout Aggregate-records tool timeout in seconds (default 30, range 1–600)
--mcp.disabled Deprecated. Disables MCP (use --mcp.enabled false)
--mcp.enabled Enable MCP (default true)
--mcp.path MCP endpoint prefix (default /mcp)

Note

MCP capability is available in version 1.7 and later.

REST section

Option Summary
--rest.disabled Deprecated. Disables REST (use --rest.enabled false)
--rest.enabled Enable REST (default true, prefer over --rest.disabled)
--rest.path REST endpoint prefix (default /api, ignored for cosmosdb_nosql)
--rest.request-body-strict Enforce strict request body validation (default false, ignored for cosmosdb_nosql)

Important

Don't mix the new --*.enabled flags and the legacy --*.disabled flags for the same subsystem in the same command. Prefer the --*.enabled pattern; the --rest.disabled, --graphql.disabled, and --mcp.disabled options log warnings and will be removed in future versions.

-c, --config

Output configuration file name. Default is dab-config.json.

Example

dab init \
  --database-type mssql \
  --config dab-config.local.json

Resulting config

{
  "data-source": {
    "database-type": "mssql",
    "connection-string": ""
  }
}

--auth.audience

JSON Web Token (JWT) audience claim.

Example

dab init \
  --database-type mssql \
  --auth.audience "https://example.com/api"

Resulting config

{
  "runtime": {
    "host": {
      "authentication": {
        "jwt": {
          "audience": "https://example.com/api"
        }
      }
    }
  }
}

--auth.issuer

JSON Web Token (JWT) issuer claim.

Example

dab init \
  --database-type mssql \
  --auth.issuer "https://login.microsoftonline.com/{tenant-id}/v2.0"

Resulting config

{
  "runtime": {
    "host": {
      "authentication": {
        "jwt": {
          "issuer": "https://login.microsoftonline.com/{tenant-id}/v2.0"
        }
      }
    }
  }
}

--auth.provider

Identity provider. Default is Unauthenticated.

When Unauthenticated is active, DAB doesn't inspect or validate any JWT. All requests run as anonymous. Another service can authenticate or filter requests before they reach DAB, but DAB still authorizes only as anonymous. To use a different provider, set it explicitly.

For configuration guidance, see Configure the Unauthenticated provider.

Note

The Data API builder 2.0 functionality described in this section is currently in preview and might change before general availability. For more information, see What's new in version 2.0.

Valid values: Unauthenticated, StaticWebApps, EntraID, AzureAD, AppService, Simulator, Custom.

Important

Providers other than Unauthenticated, StaticWebApps, and Simulator require --auth.audience and --auth.issuer.

Example

dab init \
  --database-type mssql \
  --auth.provider AzureAD \
  --auth.audience "https://example.com/api" \
  --auth.issuer "https://login.microsoftonline.com/{tenant-id}/v2.0"

Resulting config

{
  "runtime": {
    "host": {
      "authentication": {
        "provider": "AzureAD",
        "jwt": {
          "audience": "https://example.com/api",
          "issuer": "https://login.microsoftonline.com/{tenant-id}/v2.0"
        }
      }
    }
  }
}

--connection-string

Database connection string. Supports @env().

Example

dab init \
  --database-type mssql \
  --connection-string "@env('MSSQL_CONNECTION_STRING')"

Resulting config

{
  "data-source": {
    "connection-string": "@env('MSSQL_CONNECTION_STRING')"
  }
}

--cors-origin

Comma-separated list of allowed origins.

Example

dab init \
  --database-type mssql \
  --cors-origin "https://app.example.com,https://admin.example.com"

Resulting config

{
  "runtime": {
    "host": {
      "cors": {
        "origins": [ "https://app.example.com", "https://admin.example.com" ]
      }
    }
  }
}

--cosmosdb_nosql-container

Cosmos DB NoSQL container name.

Example

dab init \
  --database-type cosmosdb_nosql \
  --cosmosdb_nosql-container MyContainer

Resulting config

{
  "data-source": {
    "database-type": "cosmosdb_nosql",
    "options": {
      "container": "MyContainer"
    }
  }
}

--cosmosdb_nosql-database

Cosmos DB NoSQL database name. Required for cosmosdb_nosql.

Example

dab init \
  --database-type cosmosdb_nosql \
  --cosmosdb_nosql-database MyDb

Resulting config

{
  "data-source": {
    "database-type": "cosmosdb_nosql",
    "options": {
      "database": "MyDb"
    }
  }
}

--database-type

Specifies the target database engine. Supported values: mssql, mysql, postgresql, cosmosdb_postgresql, cosmosdb_nosql.

Example

dab init \
  --database-type mssql

Resulting config

{
  "data-source": {
    "database-type": "mssql"
  }
}

--graphql.disabled

Deprecated. Disables GraphQL. Prefer --graphql.enabled false.

--graphql.enabled

Enable GraphQL endpoint. Default is true.

Example

dab init \
  --database-type mssql \
  --graphql.enabled false

Resulting config

{
  "runtime": {
    "graphql": {
      "enabled": false
    }
  }
}

--graphql.multiple-create.enabled

Allows creating multiple rows in a single mutation. Default is false.

Example

dab init \
  --database-type mssql \
  --graphql.multiple-create.enabled true

Resulting config

{
  "runtime": {
    "graphql": {
      "multiple-mutations": {
        "create": { "enabled": true }
      }
    }
  }
}

--graphql.path

GraphQL endpoint prefix. Default is /graphql.

Example

dab init \
  --database-type mssql \
  --graphql.path /gql

Resulting config

{
  "runtime": {
    "graphql": {
      "path": "/gql"
    }
  }
}

--graphql-schema

Path to a GraphQL schema file. Required for cosmosdb_nosql.

Example

dab init \
  --database-type cosmosdb_nosql \
  --graphql-schema ./schema.gql

Resulting config

{
  "data-source": {
    "database-type": "cosmosdb_nosql",
    "options": {
      "schema": "./schema.gql"
    }
  }
}

--host-mode

Host mode. Default is Production.

Valid values: Development, Production.

Example

dab init \
  --database-type mssql \
  --host-mode development

Resulting config

{
  "runtime": {
    "host": {
      "mode": "development"
    }
  }
}

--mcp.aggregate-records.query-timeout

Execution timeout in seconds for the aggregate-records MCP tool. Default is 30. Range: 1600.

Example

dab init \
  --database-type mssql \
  --mcp.aggregate-records.query-timeout 60

Resulting config

{
  "runtime": {
    "mcp": {
      "dml-tools": {
        "aggregate-records": {
          "query-timeout": 60
        }
      }
    }
  }
}

--mcp.disabled

Deprecated. Disables MCP. Prefer --mcp.enabled false.

--mcp.enabled

Enable MCP endpoint. Default is true.

Example

dab init \
  --database-type mssql \
  --mcp.enabled false

Resulting config

{
  "runtime": {
    "mcp": {
      "enabled": false
    }
  }
}

--mcp.path

MCP endpoint prefix. Default is /mcp.

Example

dab init \
  --database-type mssql \
  --mcp.path /model

Resulting config

{
  "runtime": {
    "mcp": {
      "path": "/model"
    }
  }
}

--rest.disabled

Deprecated. Disables REST. Prefer --rest.enabled false.

--rest.enabled

Enable REST endpoint. Default is true.

Example

dab init \
  --database-type mssql \
  --rest.enabled false

Resulting config

{
  "runtime": {
    "rest": {
      "enabled": false
    }
  }
}

--rest.path

REST endpoint prefix. Default is /api.

Note

Ignored for cosmosdb_nosql.

Example

dab init \
  --database-type mssql \
  --rest.path /rest

Resulting config

{
  "runtime": {
    "rest": {
      "path": "/rest"
    }
  }
}

--rest.request-body-strict

Controls handling of extra fields in request bodies. Default is false.

  • true: Rejects extraneous fields (HTTP 400).
  • false: Ignores extra fields.

Note

Ignored for cosmosdb_nosql.

Example

dab init \
  --database-type mssql \
  --rest.request-body-strict false

Resulting config

{
  "runtime": {
    "rest": {
      "request-body-strict": false
    }
  }
}

--runtime.base-route

Global prefix prepended to all endpoints. Must begin with /.

Important

This option requires the authentication provider to be StaticWebApps. Set --auth.provider StaticWebApps alongside --runtime.base-route.

Example

dab init \
  --database-type mssql \
  --auth.provider StaticWebApps \
  --runtime.base-route /v1

Resulting config

{
  "runtime": {
    "base-route": "/v1"
  }
}

--set-session-context

Enable sending data to SQL Server using session context. Only valid for mssql. Default is false.

Example

dab init \
  --database-type mssql \
  --set-session-context true

Resulting config

{
  "data-source": {
    "database-type": "mssql",
    "options": {
      "set-session-context": true
    }
  }
}