Announcing Data API Builder (Preview) for PostgreSQL
Published Mar 15 2023 09:00 AM 3,356 Views
Microsoft

Today we are thrilled to announce public preview of Data API Builder.

 

Data API Builder eliminates much of the complexity to build GraphQL API or REST APIs and provides secure access to your data

when using traditional approaches that require significant custom code and extended development time. With Data API Builder (DAB) your database objects such as tables and views can be quickly exposed as REST or GraphQL endpoints enabling secure and fast access to your data from any platform, with any language, and using any device.

 

GaryHope_0-1678832022858.png

 

With support for PostgreSQL, Azure SQL, SQL Server, MySQL and Azure Cosmos DB, you have the freedom to select the database technology you prefer. If you prefer PostgreSQL whether it’s a fully managed cloud service such as Azure Database for PostgreSQL or a self-hosted offline instance of the PostgreSQL engine Data API builder has your back.

 

PostgreSQL Service

Data API Builder Support

any PostgreSQL Server

Yes

Azure Database for PostgreSQL Flexible Server

Yes

Azure Database for PostgreSQL Single Server

Yes

Azure Cosmos DB for PostgreSQL

Yes

 

Data API Builder provides built-in data access authentication and authorization that enables you to securely access your data when using the built-in role-based access control that meets the needs of your application.

 

As a developer you can use the languages and frameworks of your choice to build your apps, whether they’re front frameworks such as Next JS or React, or more traditional frameworks in languages such as Python, PHP, Java or C#. 

 

Boosting your productivity is easy: you can instantly stand up a GraphQL and/or REST endpoint with no code by simply installing the Data API Builder runtime, providing the connection string, basic schema and permissions information.  It has a dedicated CLI, the Data API builder (DAB) CLI, that allows you to run Data API builder on your machine and manage everything needed to have Data API builder up and running locally. In fact, aside the PostgreSQL Server or Azure Database for PostgreSQL Server, a configuration file is all you need:

 

dab init --database-type postgesql --connection-string "@env('AZURE_PG_CONNSTR')"
dab add Book --source dbo.books --permissions "anonymous:*"
dab start

 

 

Data API builder is a .NET core (so it runs on any OS: Windows, Linux and MacOS) application and is distributed via NuGet, so that it can be installed using dotnet tool. Just run:

dotnet tool install --global Microsoft.DataApiBuilder

 

and you will be good to go. 

 

Have a look at the Data API Builder Quick Start to get started with Data API Builder and PostgreSQL.

 

Best of both REST and GraphQL endpoints

 

Data API builder supports both REST and GraphQL and gives you flexibility to choose the type of API that works best for your application and data.

 

Many developers love GraphQL APIs with their single endpoint and broad range of GraphQL API benefits:

  • Declarative data fetching – define the data structure you want your application to receive and enable clear separation of concerns within the application.
  • No more over fetching and under fetching – applications request exactly what they need and nothing more, helping you save time when fetching data in your application.
  • Strongly typed shema and Introspection – API’s with strongly typed self-documenting schema are less prone to errors as queries can be properly validated.
  • Language agnostic - Developers can build applications using Data API Builder with any platform, any language, and any device of their choice.

 

Out of the box integration with Azure Static Web Apps

 

Data API Builder is tightly integrated into Azure Static Web Apps (SWA), providing the ability to efficiently build dynamic web apps at scale. You can get started building your apps without investing in separate backend development efforts to create APIs for data access. You can focus on writing the code that makes a difference to your users. Data API Builder supports Azure Database for PostgreSQL- Flexible Server and Azure Database for PostgreSQL - Single Server.

 

GaryHope_1-1678832060244.png

 

By connecting your PostgreSQL database to your Static Web Apps resource, you can make REST or GraphQL requests within your frontend client code using the `/data-api` endpoint. CRUD (Create, Read, Update, Delete) requests can also be made to the /data-api/api/<Entity> using the standard POST/GET/PUT/DELETE method headers and the return or request bodies will match your database column headers. You can also make GraphQL queries or mutations to the /data-api/graphql endpoint, using fetch or any GraphQL library you wish.   

 

DAB SWA Annoucement Screenshot PostgreSQL v0.01.png

 

The tight integration with Azure Static Web Apps additionally provides Managed Identity support for your AAD enabled Azure Database for PostgreSQL- Single Server, enabling you to provide a well authenticated trusted API without the added complexity of managing credentials in your application. With this initial preview release of Data API Builder integration with Azure Static Web Apps some work remains: We are committed to providing Azure Static Web App support for Azure Cosmos DB for PostgreSQL along with support for Azure Database for PostgreSQL - Flexible Server with managed identity support.

 

Azure PostgreSQL Service

DAB + SWA with Password auth

DAB + SWA with AAD auth

Azure Database for PostgreSQL Flex Server

Yes

Coming soon

Azure Database for PostgreSQL Single Server

Yes

Yes

Azure Cosmos DB for PostgreSQL

Coming soon

No

 

Contribute

 

Data API builder is Open Source, and we are thrilled for getting your ideas and feedback on how to improve Data API builder. Use the “Discussion” page available in the GitHub repo, to start a discussion, propose an idea or provide some feedback and keep it going.

 

Source code is available here: https://aka.ms/dab

 

Get started!

 

Check out Data API Builder documentation to get started. For more details on the integration with Azure Static Web Apps see Azure Static Web Apps Database Connections

If you don’t have an Azure subscription, try Azure for free.

We are always eager to hear your feedback so please reach out via email using Ask Azure DB for PostgreSQL. 

Co-Authors
Version history
Last update:
‎Mar 15 2023 08:16 PM
Updated by: