You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance Entra ID setup script and documentation for Evidence Portal workshop
- Updated PowerShell script to provide a comprehensive, idempotent setup for Entra ID app registrations, including detailed steps for creating API and SPA apps, configuring OAuth2 scopes, app roles, and service principals.
- Improved parameter descriptions and added optional parameters for production redirect URI and API scope name.
- Enhanced error handling and logging for better user feedback during execution.
- Revised workshop guides to reflect the new script capabilities, emphasizing the automated setup process and its benefits.
- Added a fast-track deployment option in the Azure deployment guide, streamlining the process for users to deploy the entire solution in one command.
Co-authored-by: Copilot <copilot@github.com>
Copy file name to clipboardExpand all lines: README.md
+75-15Lines changed: 75 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,49 +87,109 @@ The sample apps work immediately without any Azure or Entra ID configuration. Th
87
87
88
88
### Bootstrap Entra ID App Registrations (PowerShell)
89
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.
90
+
[scripts/setup-entra-apps.ps1](scripts/setup-entra-apps.ps1) is an idempotent PowerShell helper that creates and fully configures 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
91
92
-
What it does today (Phase 1):
92
+
What it does (every call is a no-op if the resource is already configured the right way):
93
93
94
94
- Verifies `az` is installed and you are signed in (`az login`).
95
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.
96
+
- Creates the **API app**, sets its Application ID URI to `api://<appId>`, exposes the `Evidence.Read` OAuth2 scope, and defines the `CaseReader` and `CaseAdmin` app roles.
97
+
- Creates the **SPA app**, configures its SPA platform redirect URI(s), grants the delegated `Evidence.Read` permission, and pre-authorizes the SPA on the API.
98
+
- Creates service principals for both apps if they don't exist yet.
99
+
- (Optional, default on) Grants tenant admin consent for the SPA's delegated permission and self-assigns the signed-in user to both `CaseReader` and `CaseAdmin` so you can sign in immediately.
100
+
- (Optional, default on) Patches the local `environment.ts`, `environment.prod.ts`, and `application.properties` files with the resulting client/tenant IDs and scope URI.
99
101
100
102
Usage:
101
103
102
104
```powershell
103
105
# Sign in to the tenant where the apps should live
104
106
az login --tenant <tenantId>
105
107
106
-
# Bootstrap both app registrations
108
+
# Bootstrap both app registrations and patch local config
107
109
.\scripts\setup-entra-apps.ps1 `
108
110
-SpaName "Evidence Portal SPA" `
109
111
-ApiName "Evidence Portal API"
110
112
111
-
# Optional: capture the resulting IDs for downstream automation (e.g. deploy.ps1)
113
+
# Re-run later with a production redirect URI (idempotent)
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)).
121
+
The script returns and prints `tenantId`, `apiAppId`, `apiObjectId`, `apiServicePrincipalId`, `apiScopeId`, `apiScopeUri`, `roleReaderId`, `roleAdminId`, `spaAppId`, `spaObjectId`, `spaServicePrincipalId`, plus the redirect URIs and consent/role-assignment status. With `-OutputFile` it also writes a JSON state file that [scripts/deploy.ps1](scripts/deploy.ps1) consumes on its next run, so you don't need to re-run setup before every deployment.
122
+
123
+
> Skip the patching or admin consent with `-UpdateLocalConfig:$false`, `-GrantAdminConsent:$false`, or `-AssignCurrentUserToRoles:$false` if you would rather wire those up by hand.
124
+
125
+
### Fast-Track to Azure (One Command)
126
+
127
+
If you want to see the deployed end-state in Azure as quickly as possible — without going through the four guided exercises — run the one-stop deployment script. It chains every step of Exercises 1 and 4 into a single idempotent run.
128
+
129
+
```powershell
130
+
# Sign in once to the tenant where the apps and Azure resources should live
131
+
az login --tenant <tenantId>
132
+
az account set --subscription <subscriptionIdOrName>
133
+
134
+
# Deploy everything (Entra ID + Bicep + SPA + API + evidence files)
135
+
.\scripts\deploy.ps1
136
+
```
137
+
138
+
What `deploy.ps1` does end-to-end:
139
+
140
+
1. Verifies `az`, `node`, `mvn` (auto-installs Maven into `%LOCALAPPDATA%\Maven` if missing).
141
+
2. Calls `setup-entra-apps.ps1` to create/reuse both app registrations, expose the scope and roles, grant admin consent, and assign your user to `CaseReader` + `CaseAdmin`.
142
+
3. Creates the resource group `rg-evidence-workshop` in `canadacentral` and a deterministic globally-unique storage account name.
143
+
4. Deploys the Bicep stack (App Service Plan, two App Services with system-assigned Managed Identity, Storage Account, Application Insights, role assignments).
144
+
5. Patches `environment.prod.ts` with the deployed SPA/API URLs and App Insights connection string.
145
+
6. Re-runs `setup-entra-apps.ps1` to add the production SPA URL as a SPA-platform redirect URI on the SPA app registration.
146
+
7. Builds the Angular SPA in production mode and the Spring Boot API as an executable JAR.
147
+
8. Deploys the SPA zip and the API JAR with `az webapp deploy`.
148
+
9. Grants your user `Storage Blob Data Contributor` on the storage account, creates the `evidence` container, and uploads the five sample PDFs (with retries to absorb RBAC propagation).
149
+
10. Smoke-tests the result: SPA URL must return `200`, API `/api/cases` must return `401` (proving JWT validation is enforced).
Open the SPA URL, sign in with the same account you ran the script as, and you should land on the case list with all five sample cases — files served from Blob Storage through the API's Managed Identity.
164
+
165
+
Common flags:
166
+
167
+
| Flag | Default | Purpose |
168
+
|---|---|---|
169
+
|`-ResourceGroup`|`rg-evidence-workshop`| Target resource group (created if missing). |
170
+
|`-Location`|`canadacentral`| Azure region. |
171
+
|`-Environment`|`workshop`| Suffix used for App Service names (`app-evidence-spa-<env>`, `app-evidence-api-<env>`). |
172
+
|`-SkipEntraSetup`| off | Reuse a previous `.entra-apps.json` and skip the Graph calls. |
173
+
|`-SkipBuild`| off | Reuse the existing `dist/` and `target/` artifacts. |
174
+
|`-SkipUpload`| off | Skip the sample-evidence blob upload. |
175
+
176
+
When you're done with the workshop, remove everything with:
177
+
178
+
```powershell
179
+
az group delete --name rg-evidence-workshop --yes --no-wait
180
+
```
120
181
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
182
123
183
### Workshop Exercises
124
184
125
-
Follow these exercises in order for the full 3-hour workshop experience:
185
+
Follow these exercises in order for the full 3-hour workshop experience. Already saw the Fast-Track land everything in Azure? You can still use these guides as a tear-down of what `deploy.ps1` automated.
126
186
127
187
| Exercise | Duration | Description |
128
188
|---|---|---|
129
-
|[Exercise 1: Configure App Registrations](workshop/guides/exercise-1-app-registrations.md)| 30 min | Create Entra ID app registrations for the SPA and API, configure scopes, roles, and update the SPA environment |
130
-
|[Exercise 2: Run SPA + API Locally](workshop/guides/exercise-2-run-locally.md)| 30 min | Sign in through the SPA, browse cases, download evidence, and inspect JWT tokens |
131
-
|[Exercise 3: Add Role-Protected Endpoint](workshop/guides/exercise-3-add-endpoint.md)| 20 min | Experience the RBAC cycle: 403 Forbidden, assign CaseAdmin role, re-authenticate, 201 Created |
132
-
|[Exercise 4: Deploy to Azure](workshop/guides/exercise-4-deploy-azure.md)| 20 min | Deploy both apps and infrastructure to Azure using Bicep, verify Managed Identity storage access |
189
+
|[Exercise 1: Configure App Registrations](workshop/guides/exercise-1-app-registrations.md)| 30 min | Create Entra ID app registrations for the SPA and API, configure scopes, roles, and update the SPA environment. (Automated end-to-end by `setup-entra-apps.ps1`.)|
190
+
|[Exercise 2: Run SPA + API Locally](workshop/guides/exercise-2-run-locally.md)| 30 min | Sign in through the SPA, browse cases, download evidence, and inspect JWT tokens.|
191
+
|[Exercise 3: Add Role-Protected Endpoint](workshop/guides/exercise-3-add-endpoint.md)| 20 min | Experience the RBAC cycle: 403 Forbidden, assign CaseAdmin role, re-authenticate, 201 Created.|
192
+
|[Exercise 4: Deploy to Azure](workshop/guides/exercise-4-deploy-azure.md)| 20 min | Deploy both apps and infrastructure to Azure using Bicep, verify Managed Identity storage access. (Automated end-to-end by `deploy.ps1`.)|
133
193
134
194
For the full instructor delivery guide with 9-module schedule and presentation notes, see [workshop/README.md](workshop/README.md).
0 commit comments