2.7 — Expose Data with Data API Builder (REST and GraphQL)
DP-800 Domain 2 · Skill 2.7
What You Need to Know
Data API builder (DAB) turns tables, views and stored procedures into secure REST and GraphQL endpoints, and optionally MCP tools, from a single configuration file, with no API code. It runs as a container or process, and it also powers Fabric's API for GraphQL.
The configuration file
dab init --database-type mssql --connection-string "@env('SQL_CONN')" --host-mode production
dab add Product --source dbo.Product --permissions "authenticated:read"
dab add Order --source dbo.usp_PlaceOrder --source.type stored-procedure --permissions "authenticated:execute"
dab start
dab-config.json has three main sections:
| Section | Contains |
|---|---|
data-source |
Database type and connection string. Use @env('...') or Key Vault references, never a literal secret |
runtime |
REST and GraphQL paths, authentication provider (EntraID, AppService, StaticWebApps), CORS, host mode, cache settings, and the MCP endpoint |
entities |
One entry per exposed object: source (object, type = table, view or stored-procedure, plus parameters), rest and graphql settings, permissions, relationships, cache |
Entities in detail
| Need | Configuration |
|---|---|
| Expose a view | source.type: view, and mark the key column (fields[].primary-key: true) so that single-item lookups and paging work |
| Expose a stored procedure | source.type: stored-procedure; the action is execute; REST methods (for example POST); GraphQL operation mutation or query |
| Permissions | permissions: [{ role: "authenticated", actions: ["read"] }, { role: "admin", actions: ["*"] }], with optional field include and exclude lists and database policies (row filters such as @item.OwnerId eq @claims.oid) |
| Relationships for GraphQL | relationships: { orders: { cardinality: "many", target.entity: "Order", source.fields: ["CustomerID"], target.fields: ["CustomerID"] } }. For many-to-many, add a linking object |
| Caching | runtime.cache.enabled: true, plus per entity cache: { enabled: true, ttl-seconds: 60 } (level L1 in memory, or L1L2 with a distributed cache) |
| Custom REST path | rest.path: "/products" |
Querying the endpoints
- REST:
GET /api/Product?$filter=Price gt 100&$orderby=Name&$select=ProductID,Name&$first=50. Paging continues with thenextLink(an$aftercursor) in the response. - GraphQL:
products(filter: { price: { gt: 100 } }, orderBy: { name: ASC }, first: 50, after: "...") { items { productID name orders { items { orderID } } } }. - Paging is cursor-based (
firstandafter), and page size limits are set in the runtime configuration.
Deployment
- Run DAB in Azure Container Apps, App Service or Kubernetes, with the config file mounted and secrets from environment variables or Key Vault. Use a managed identity for the database connection.
- Azure Static Web Apps database connections and Fabric API for GraphQL offer DAB-based hosting that's managed for you.
- Keep
dab-config.jsonin source control next to the database project, and deploy both through the pipeline.
Key Concept: One dab-config.json defines data source, runtime and entities. Entities control REST, GraphQL, permissions per role, relationships and caching. Views need a declared key, and stored procedures use the execute action.
Exam Traps
- Exposing a view without declaring its key fields
- Giving the
anonymousrole write actions on business tables - Writing the connection string with a password into the committed config file
- Expecting GraphQL nested queries (orders under a customer) without defining a relationship
Check your understanding
Practice Scenario
🔒 This practice scenario is part of Skillmarked Pro
The lessons stay free. Pro unlocks the other 14 DP-800 practice scenarios and the 50-question timed mock exam, plus everything for every other exam.
Launch Deal: first month €9.95, then €19.90/month. Enter code LAUNCH50 at checkout. Ends 1 December.
Cancel anytime. Or €199 a year, which saves 17%.
Not sure yet? Try 10 free mock exam questions.
Already Pro? Log in.
Sources
- What is Data API builder?, Microsoft Learn
- Configuration schema: entities, Microsoft Learn
- Configuration schema: runtime, Microsoft Learn
- Host REST and GraphQL endpoints (deployment), Microsoft Learn