Skip to content

Commit 2e17577

Browse files
emmanuelknafoCopilot
andcommitted
feat: add PowerShell script to bootstrap Entra ID app registrations for the workshop
Co-authored-by: Copilot <copilot@github.com>
1 parent f516b1b commit 2e17577

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,41 @@ The sample apps work immediately without any Azure or Entra ID configuration. Th
8585

8686
> **Note:** The "Sign In" button will fail until you complete Exercise 1 (Entra ID app registration). The API endpoints are fully functional without authentication in dev mode.
8787
88+
### Bootstrap Entra ID App Registrations (PowerShell)
89+
90+
[scripts/setup-entra-apps.ps1](scripts/setup-entra-apps.ps1) is an idempotent PowerShell helper that creates the SPA and API app registrations against the tenant you are currently logged in to with the Azure CLI. It is the fastest path through Exercise 1 if you prefer scripting over the Azure Portal.
91+
92+
What it does today (Phase 1):
93+
94+
- Verifies `az` is installed and you are signed in (`az login`).
95+
- Acquires a Microsoft Graph access token and calls Graph directly via `Invoke-RestMethod` (no `az rest` quoting issues on Windows).
96+
- Creates the **API app** and sets its Application ID URI to `api://<appId>`.
97+
- Creates the **SPA app** and configures its SPA platform redirect URI (default `http://localhost:4200`).
98+
- On re-run, looks each app up by `displayName` and reuses it instead of creating duplicates. Every step is a no-op if already configured.
99+
100+
Usage:
101+
102+
```powershell
103+
# Sign in to the tenant where the apps should live
104+
az login --tenant <tenantId>
105+
106+
# Bootstrap both app registrations
107+
.\scripts\setup-entra-apps.ps1 `
108+
-SpaName "Evidence Portal SPA" `
109+
-ApiName "Evidence Portal API"
110+
111+
# Optional: capture the resulting IDs for downstream automation (e.g. deploy.ps1)
112+
.\scripts\setup-entra-apps.ps1 `
113+
-SpaName "Evidence Portal SPA" `
114+
-ApiName "Evidence Portal API" `
115+
-RedirectUri "https://my-spa.azurewebsites.net" `
116+
-OutputFile ".\.entra-apps.json"
117+
```
118+
119+
The script returns and prints `tenantId`, `apiAppId`, `apiObjectId`, `identifierUri`, `spaAppId`, `spaObjectId`, and `redirectUri`. Plug `tenantId`, `apiAppId`, and `spaAppId` into [`environment.ts`](sample-app/spa/src/environments/environment.ts) and [`application.properties`](sample-app/api/src/main/resources/application.properties) (or pass them to [scripts/deploy.ps1](scripts/deploy.ps1)).
120+
121+
> **Phase 2 (planned):** the same script will be extended via Microsoft Graph to expose the `Evidence.Read` scope, define `CaseReader` / `CaseAdmin` app roles, add the SPA's delegated permission on the API, pre-authorize the SPA, and grant tenant admin consent. Until then, complete those steps in the Azure Portal as described in [Exercise 1](workshop/guides/exercise-1-app-registrations.md).
122+
88123
### Workshop Exercises
89124

90125
Follow these exercises in order for the full 3-hour workshop experience:
@@ -125,7 +160,8 @@ msal-java/
125160
│ ├── start.sh # Start both apps locally (macOS/Linux)
126161
│ ├── deploy.ps1 # Full Azure deployment (PowerShell)
127162
│ ├── deploy.sh # Full Azure deployment (Bash)
128-
│ ├── setup-entra-apps.sh # Automate app registrations
163+
│ ├── setup-entra-apps.ps1 # Idempotent app registration bootstrap (PowerShell, Graph API)
164+
│ ├── setup-entra-apps.sh # Automate app registrations (Bash, az CLI)
129165
│ └── configure-app-settings.sh # Post-deploy configuration
130166
├── docs/
131167
│ └── production-hardening.md # PE, VNet, DNS for production

0 commit comments

Comments
 (0)