Skip to content

Commit

Permalink
v1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Spendolini authored and Brian Spendolini committed Aug 5, 2024
1 parent ddb4ff5 commit 6510974
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions docs/3-Data-API-builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ Also, Data API builder is Open Source and works on any platform; on-premises, in

## Data API builder workshop tasks

### REST/GraphQL enable a table
### Setting the connect string in a .env file

> **Step one is important. Be sure to be back in the main directory for this section of the workshop.**
> [!IMPORTANT]
> **This section is important. Be sure to be back in the main directory for this section of the workshop.**
1. Back in your codespace, at the terminal at the bottom of the page, **return to the main directory**

```bash
cd /workspaces/azure-sql-db-developers-workshop
```

1. Next step is to create the Data API Builder initialization file. You need to get the connection string to connect to the `devDB` database that you created before. Since Data API builder is a .NET application, you can get the correct connection string using the following command:
1. Next step is to put our database connection string into a local .env file so it is not hardcoded into the Data API builder init file. You need to get the connection string to connect to the `devDB` database that you created in chapter 2. Since Data API builder is a .NET application, you can get the correct connection string using the following command:

```bash
sqlcmd config connection-strings --database devDB | grep ADO.NET
Expand All @@ -46,7 +47,7 @@ Also, Data API builder is Open Source and works on any platform; on-premises, in

Now, since the connection string is using a login/password pair, we're going to use environment variables to avoid storing the connection string in the Data API Builder configuration file.
Create an environment file:
1. Create an environment file by running the following code in the terminal:
```bash
touch .env
Expand All @@ -56,18 +57,20 @@ Also, Data API builder is Open Source and works on any platform; on-premises, in
![A picture of clicking the .env file in the file navigator and click it to bring it up in the code editor](./media/ch3/dab0a1.png)
1. Add the connection string to the environment file from Visual Studio Code, setting the `MSSQL` variable to the connection string you obtained in the previous step:
1. Add the connection string to the environment file from Visual Studio Code, setting the `MSSQL` variable to the connection string you obtained in a previous step:
> [!IMPORTANT]
> Remeber to use the ADO.NET connection string in the .env file.
```text
MSSQL='THE ADO.NET CONNECTION STRING YOU COPIED FROM RUNNING sqlcmd config connection-strings --database devDB | grep ADO.NET'
MSSQL='THE ADO.NET CONNECTION STRING YOU COPIED'
```
![The connection string saved in the environment file](./media/ch3/dab0.png)
> [!IMPORTANT]
> Remeber to use the ADO.NET connection string in the .env file.
### Creating the init file
5. Then, you can use the Data API Builder (DAB) CLI to initialize the configuration file:
1. Then, you can use the Data API Builder (DAB) CLI to initialize the configuration file:
```bash
dab init --database-type "mssql" --connection-string "@env('MSSQL')" --host-mode "Development" --rest.path "rest"
Expand Down

0 comments on commit 6510974

Please sign in to comment.