page_type | languages | products | name | description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
|
|
AdventureWorks LT Data API builder |
Expose the sample database Adventure Works LT as a REST and GraphQL API via Data API builder |
Expose the sample database Adventure Works LT as a REST and GraphQL API via Data API builder
Create an Azure SQL database using the AdventureWorksLT sample database. You can follow the instructions in the following article: Quickstart: Create a single database - Azure SQL Database. Make sure to allow Azure Service to connect to the database, by selecting Yes for the Allow Azure services to access server option.
Connect to the created Azure SQL database and run the following script to create a user:
create user dab_adw_user with password = '2_we2KWE-1S!cca';
grant select on schema::SalesLT to dab_adw_user;
In a Linux shell (using Linux, WSL or the Cloud Shell) make sure you have AZ CLI installed and then run the azure-deploy.sh
script. If it is the first time you're running the script, it will create a .env
file and then stop.
Fill the .env
file with the required values and run the script again. The connection string for the Azure SQL database can be found in the Azure portal, in the Azure SQL database blade, under the Connection strings section. Make sure to use the created dab_adw_user
. For example:
MSSQL='Server=<server>.database.windows.net;Database=AdventureWorksLT;User ID=dab_adw_user;Password=2_we2KWE-1S!cca;'
This will create the following resources:
- Resource Group
- Storage Account
- App Service Plan (B1)
- Web App
Data API builder will be executed as a Docker container in the Web App.
The deployment will pull the Docker image from mcr.microsoft.com/azure-databases/data-api-builder:latest
. Please wait a couple of minutes before testing the API, to allow the Docker image to be pulled and the container to be started.
You can test if the everything is up and running by running thw following command:
curl https:/<web-app-name>.azurewebsites.net/
and it should return the string "Healthy". If it doesn't, wait for a few seconds and try again, as the container may still be starting.
Once everything has been deployed, you can test the API by opening the following URL in a browser:
http://<web-app-name>.azurewebsites.net/swagger
or, for GraphQL
http://<web-app-name>.azurewebsites.net/graphql
To automatically expose all tables in the database, you can start from the sql-to-dab-config.sql
sample scripts. Make sure to review the script and customize it to your needs. For example, you may want to rename and customize the relationships created from the Address
entity to the SalesOrderHeader
entity, to set a better name of the relationship based on the ShipToAddressID
and BillToAddressID
fields.