| title | Use configuration file environments in Data API builder |
|---|---|
| description | Learn how to use environments in Data API builder to manage configuration differences between development and production. |
| author | seesharprun |
| ms.author | sidandrews |
| ms.reviewer | jerrynixon |
| ms.service | data-api-builder |
| ms.topic | how-to |
| ms.date | 06/11/2025 |
Data API builder supports multiple configuration environments, similar to ASP.NET Core's appsettings.json. You can define a base configuration (dab-config.json) and environment-specific variants (dab-config.Development.json, dab-config.Production.json). This feature enables the flexible management of connection strings, authentication settings, and other configuration changes across environments.
DEV_CONNECTION_STRING=Server=tcp:127.0.0.1,1433;User ID=<username>;Password=<password>;
PROD_CONNECTION_STRING=Server=tcp:127.0.0.1,1433;User ID=<username>;Password=<password>;Note
The .env file has no filename, only an extension.
dab init --database-type "mssql" --connection-string ""
dab add Book --source "dbo.Books" --permissions "anonymous:*"This step produces a basic dab-config.json file that is shared across all environments.
- dab-config.json
- dab-config.Development.json
- dab-config.Production.json
{
"data-source": {
"connection-string": "@env('DEV_CONNECTION_STRING')"
}
}{
"data-source": {
"connection-string": "@env('PROD_CONNECTION_STRING')"
}
}Note
Environment-specific files override the base configuration when DAB_ENVIRONMENT is set.
Use this command to set the environment to Development:
DAB_ENVIRONMENT=Development dab startUse this command to set the environment to Production:
DAB_ENVIRONMENT=Production dab startNote
If no environment is set, the default environment is Production.
- REST:
http://localhost:5000/api/Book - GraphQL:
http://localhost:5000/graphql - Swagger:
http://localhost:5000/swagger - Health:
http://localhost:5000/health