Skip to content

Commit 33d05b7

Browse files
committed
Updated labs to also use MS Entra
1 parent bfe8a61 commit 33d05b7

7 files changed

Lines changed: 223 additions & 161 deletions

‎Instructions/Labs/02-implement-programmability-objects.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Encapsulate a business operation that adds an order line item to an existing ord
141141
END;
142142
```
143143
144-
This stored procedure performs a transactional insert of a new line item. It first validates that the product and order exist—rolling back and throwing an error if either is invalid. After inserting the detail row with the product's list price, it recalculates the order's subtotal from all line items and updates the header. Wrapping everything in a transaction ensures the operation is atomic: either all changes succeed or none are applied.
144+
This stored procedure performs a transactional insert of a new line item. It first validates that the product and order exist--rolling back and throwing an error if either is invalid. After inserting the detail row with the product's list price, it recalculates the order's subtotal from all line items and updates the header. Wrapping everything in a transaction ensures the operation is atomic: either all changes succeed or none are applied.
145145
146146
1. Execute the following T-SQL code to test the stored procedure.
147147

‎Instructions/Labs/06-optimize-database-performance.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ First, create an Azure SQL Database with sample data.
4949
| **Database name** | *AdventureWorksLT* |
5050
| **Server** | Select **Create new** and create a new server with a unique name. Select your **Location**. For authentication, select one of the following options and then select **OK**: |
5151

52-
> 📝 **Authentication is not optional** — you must choose the method that matches your organization's security policies. Each option affects how you connect to the database later:
52+
> 📝 **Authentication is not optional.** You must choose the method that matches your organization's security policies. Each option affects how you connect to the database later:
5353
> - **Use Microsoft Entra-only authentication** *(recommended)*: Select this if your organization requires Entra-based access. Set your Azure account as the **Microsoft Entra admin**. You connect to the database using your Microsoft Entra account (for example, in SSMS select *Authentication* = **Microsoft Entra MFA**).
54-
> - **Use both SQL and Microsoft Entra authentication/SQL authentication**: Select this if you prefer a SQL admin login or your organization allows both methods. Provide a **Server admin login** and **Password** — you need these credentials to connect. You can also set a **Microsoft Entra admin** to enable Entra logins alongside SQL auth.
54+
> - **Use both SQL and Microsoft Entra authentication/SQL authentication**: Select this if you prefer a SQL admin login or your organization allows both methods. Provide a **Server admin login** and **Password**. You need these credentials to connect. You can also set a **Microsoft Entra admin** to enable Entra logins alongside SQL auth.
5555
5656
> 📝 If you already have a test server you can use, select it instead of creating a new one.
5757

‎Instructions/Labs/07-implement-cicd-sql-database-projects.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ First, create an Azure SQL Database with sample data.
5353
| **Database name** | *AdventureWorksLT* |
5454
| **Server** | Select **Create new** and create a new server with a unique name. Select your **Location**. For authentication, select one of the following options and then select **OK**: |
5555

56-
> 📝 **Authentication is not optional** — you must choose the method that matches your organization's security policies. Each option affects how you connect to the database later:
56+
> 📝 **Authentication is not optional.** You must choose the method that matches your organization's security policies. Each option affects how you connect to the database later:
5757
> - **Use Microsoft Entra-only authentication** *(recommended)*: Select this if your organization requires Entra-based access. Set your Azure account as the **Microsoft Entra admin**. You connect to the database using your Microsoft Entra account (for example, in SSMS select *Authentication* = **Microsoft Entra MFA**).
58-
> - **Use both SQL and Microsoft Entra authentication/SQL authentication**: Select this if you prefer a SQL admin login or your organization allows both methods. Provide a **Server admin login** and **Password** — you need these credentials to connect. You can also set a **Microsoft Entra admin** to enable Entra logins alongside SQL auth.
58+
> - **Use both SQL and Microsoft Entra authentication/SQL authentication**: Select this if you prefer a SQL admin login or your organization allows both methods. Provide a **Server admin login** and **Password**. You need these credentials to connect. You can also set a **Microsoft Entra admin** to enable Entra logins alongside SQL auth.
5959
6060
> 📝 If you already have a test server you can use, select it instead of creating a new one.
6161

‎Instructions/Labs/08-integrate-sql-solutions-azure-services.md‎

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,34 @@ You are a database developer who needs to expose product catalog data through mo
2727

2828
- An [Azure subscription](https://azure.microsoft.com/free)
2929
- [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) installed and signed in to your subscription
30-
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed and running (for local testing)
31-
- A code editor such as [Visual Studio Code](https://code.visualstudio.com/download)
30+
- A code editor such as [Visual Studio Code](https://code.visualstudio.com/download) and the [SQL Server (mssql) extension](https://marketplace.visualstudio.com/items?itemName=ms-mssql.mssql) installed
3231
- Access to an Azure SQL Database or SQL Server instance
32+
- Dotnet SDK 8.0 or later installed.
3333

3434
---
3535

3636
## Set up the sample database
3737

3838
Before configuring Data API Builder, you need a database with tables and sample data.
3939

40-
1. Connect to your SQL Server or Azure SQL Database using Azure Data Studio or SQL Server Management Studio.
40+
1. Connect to your SQL Server or Azure SQL Database using SQL Server Management Studio (SSMS) or Visual Studio Code with the SQL Server (mssql) extension. For your database, select **master** if not already selected.
4141

4242
1. Create a new database for this exercise:
4343

4444
```sql
4545
CREATE DATABASE ProductCatalog;
4646
GO
47-
47+
```
48+
49+
If you created the database in a SQL Server (not Azure SQL Database), switch to the new database:
50+
51+
```sql
4852
USE ProductCatalog;
4953
GO
5054
```
5155

56+
If you created the database in Azure SQL Database, select the new database from the database dropdown in SSMS or Visual Studio Code, or open a **New Query** window and set the context to the new database.
57+
5258
1. Create the tables for the product catalog:
5359

5460
```sql
@@ -174,11 +180,13 @@ Use the DAB CLI to create a baseline configuration file.
174180
}
175181
```
176182

183+
> 💡 The `dab-config.json` file defines the Data API Builder configuration, including the data source, runtime settings, and entities that will be exposed through the API. Your current settings might differ to the previous example depending on your environment and the database you are connecting to. Your settings will at least include the @env('DATABASE_CONNECTION_STRING') variable, the /api and /graphql paths in the `runtime` section, your mode set to development, and an empty `entities` object.
184+
177185
---
178186

179187
## Add entities for tables
180188

181-
Add the Categories and Products tables as API entities.
189+
On the terminal or in a command prompt, add the Categories and Products tables as API entities.
182190

183191
1. Use the CLI to add the Categories entity:
184192

@@ -198,7 +206,7 @@ Add the Categories and Products tables as API entities.
198206
dab update Product --permissions "authenticated:*"
199207
```
200208

201-
1. Open `dab-config.json` to see the generated entities:
209+
1. Open `dab-config.json` to see the generated entities (your file might look slightly different depending on your environment):
202210

203211
```json
204212
"entities": {
@@ -253,7 +261,7 @@ Enhance the Product entity with field mappings and a relationship to Category.
253261

254262
The `mappings` section renames database columns to more API-friendly names. The `relationships` section enables GraphQL clients to navigate from a product to its category.
255263

256-
1. Add the reverse relationship to the Category entity:
264+
1. Add the reverse relationship to the Category entity, replacing the existing Category entity section in `dab-config.json` with the following:
257265

258266
```json
259267
"Category": {
@@ -272,6 +280,8 @@ Enhance the Product entity with field mappings and a relationship to Category.
272280
}
273281
```
274282

283+
1. Save the changes to `dab-config.json`.
284+
275285
---
276286

277287
## Add the view as a read-only entity
@@ -304,19 +314,31 @@ Expose the ProductCatalogView for clients who need combined product and category
304314
305315
---
306316
307-
## Test locally with Docker
317+
## Test locally
308318
309-
Run Data API Builder locally to verify your configuration.
319+
Run Data API Builder locally to verify your configuration. The `dab start` command launches a local web server using the .NET runtime and connects to your database using the connection string you provide.
310320
311-
1. Set the database connection string as an environment variable. Replace the placeholder with your actual connection string:
321+
1. Open a **PowerShell** or **Bash** terminal. The remaining commands in this section must be run in PowerShell or Bash (not CMD). If you are currently in a CMD prompt, type `pwsh` and press Enter to switch to PowerShell (notice the prompt changes to `PS`).
312322
313-
```bash
314-
# For PowerShell
315-
$env:DATABASE_CONNECTION_STRING="Server=your-server;Database=ProductCatalog;User Id=your-user;Password=your-password;TrustServerCertificate=true"
316-
317-
# For Bash
318-
export DATABASE_CONNECTION_STRING="Server=your-server;Database=ProductCatalog;User Id=your-user;Password=your-password;TrustServerCertificate=true"
319-
```
323+
1. Set the database connection string as an environment variable. Use **one** of the two options below depending on how your SQL server was configured for authentication.
324+
325+
> 📝 When you (or your admin) created the Azure SQL server, you chose an authentication method based on your organization's security policies. That same choice determines the connection string you use here. If you are unsure which method was configured, check the Azure portal: navigate to your SQL server > **Settings** > **Microsoft Entra ID**. If an Entra admin is set and the **Support only Microsoft Entra authentication for this server** checkbox is checked, use Option A.
326+
327+
**Option A: Microsoft Entra authentication** (no username/password needed; uses your signed-in Azure identity)
328+
329+
| Shell | Command |
330+
| --- | --- |
331+
| **PowerShell** | `$env:DATABASE_CONNECTION_STRING="Server=your-server.database.windows.net;Database=ProductCatalog;Authentication=Active Directory Default;TrustServerCertificate=true"` |
332+
| **Bash** | `export DATABASE_CONNECTION_STRING="Server=your-server.database.windows.net;Database=ProductCatalog;Authentication=Active Directory Default;TrustServerCertificate=true"` |
333+
334+
**Option B: SQL authentication** (use the admin login and password from server creation)
335+
336+
| Shell | Command |
337+
| --- | --- |
338+
| **PowerShell** | `$env:DATABASE_CONNECTION_STRING="Server=your-server.database.windows.net;Database=ProductCatalog;User Id=your-user;Password=your-password;TrustServerCertificate=true"` |
339+
| **Bash** | `export DATABASE_CONNECTION_STRING="Server=your-server.database.windows.net;Database=ProductCatalog;User Id=your-user;Password=your-password;TrustServerCertificate=true"` |
340+
341+
> 💡 Replace `your-server` with your actual server name. For Option B, also replace `your-user` and `your-password` with the admin credentials you set during server creation.
320342

321343
1. Start Data API Builder:
322344

@@ -328,9 +350,11 @@ Run Data API Builder locally to verify your configuration.
328350

329351
You should see a JSON response with product data using the mapped field names (id, name, price, stockQuantity).
330352

353+
> 📝 **If you used Option A (Microsoft Entra)** and get an error about `DefaultAzureCredential failed to retrieve a token`, your Azure CLI session may have expired. Run `az login --scope https://database.windows.net//.default` in your terminal to re-authenticate, then run `dab start` again.
354+
331355
1. Navigate to `http://localhost:5000/graphql` to access the GraphQL playground.
332356

333-
1. Run a GraphQL query that uses the relationship:
357+
1. Select **Create Document** to open a new query tab. Paste the following GraphQL query and press **Ctrl+Alt+Enter** (or select the **Run** button) to execute it:
334358

335359
```graphql
336360
query {
@@ -349,7 +373,7 @@ Run Data API Builder locally to verify your configuration.
349373

350374
The response includes product information with the related category name, demonstrating the configured relationship.
351375

352-
1. Press `Ctrl+C` to stop Data API Builder.
376+
1. Go back to the terminal and press `Ctrl+C` to stop Data API Builder.
353377

354378
---
355379

0 commit comments

Comments
 (0)