| title | Exercise 1: Configure App Registrations |
|---|---|
| description | Step-by-step guide for creating and configuring two Entra ID app registrations for the SPA and API |
| ms.date | 2026-04-20 |
| ms.topic | tutorial |
| estimated_reading_time | 5 |
Create and configure two Entra ID app registrations: one for the Spring Boot API and one for the Angular SPA. By the end of this exercise, both applications have the configuration values needed to authenticate users and authorize API calls.
Duration: 30 minutes
Navigate to https://entra.microsoft.com and sign in with your workshop account. Go to Identity > Applications > App registrations.
- Select New registration.
- Set the name to
Evidence API - <your-initials>(for example,Evidence API - JD). - Under Supported account types, select Accounts in this organizational directory only (Single tenant).
- Leave Redirect URI blank (the API does not need one).
- Select Register.
- Record the Application (client) ID and Directory (tenant) ID from the Overview page.
-
In the API registration, go to Manage > Expose an API.
-
Select Add next to Application ID URI. Accept the default value (
api://<client-id>) and select Save. -
Select Add a scope with these values:
Field Value Scope name Evidence.ReadWho can consent Admins and users Admin consent display name Read evidence data Admin consent description Allows the app to read evidence cases and files on behalf of the signed-in user State Enabled -
Select Add scope.
-
In the API registration, go to Manage > App roles.
-
Select Create app role and create two roles:
Display Name Value Allowed Member Types Description Case Reader CaseReaderUsers/Groups Can view cases and download evidence Case Admin CaseAdminUsers/Groups Can create and manage cases -
Verify both roles show Enabled status.
- Return to App registrations and select New registration.
- Set the name to
Evidence SPA - <your-initials>. - Under Supported account types, select Accounts in this organizational directory only (Single tenant).
- Under Redirect URI, select platform Single-page application (SPA) and enter
http://localhost:4200. - Select Register.
- Record the Application (client) ID from the Overview page.
- In the SPA registration, go to Manage > API permissions.
- Select Add a permission > My APIs and find the
Evidence APIregistration. - Select Delegated permissions, check
Evidence.Read, and select Add permissions. - If available, select Grant admin consent for the directory.
- Return to the API registration and go to Manage > Expose an API.
- Under Authorized client applications, select Add a client application.
- Enter the SPA's Application (client) ID.
- Check the
Evidence.Readscope. - Select Add application.
Collect these values from the Azure portal. You need them for the next two steps.
| Value | Where to Find It |
|---|---|
| Tenant ID | API registration > Overview > Directory (tenant) ID |
| API Client ID | API registration > Overview > Application (client) ID |
| API Scope URI | API registration > Expose an API > api://<api-client-id>/Evidence.Read |
| SPA Client ID | SPA registration > Overview > Application (client) ID |
Open sample-app/spa/src/environments/environment.ts and replace the placeholder values:
export const environment = {
production: false,
msalConfig: {
auth: {
clientId: '<SPA-CLIENT-ID>',
authority: 'https://login.microsoftonline.com/<TENANT-ID>',
redirectUri: 'http://localhost:4200',
},
},
apiConfig: {
uri: 'http://localhost:8080/api',
scopes: ['api://<API-CLIENT-ID>/Evidence.Read'],
},
};The API uses standard Spring Security OAuth2 Resource Server for JWT validation. The dev profile runs without JWT validation so you can explore the API immediately. For production deployment (Exercise 4), the JWT issuer URI and audience are set via environment variables.
No changes to application-dev.properties are needed at this point. The API configuration is updated during deployment in Exercise 4.
Note: If you want to enable JWT validation locally, set these environment variables before starting the API:
export JWT_ISSUER_URI=https://login.microsoftonline.com/<TENANT-ID>/v2.0 export JWT_AUDIENCE=api://<API-CLIENT-ID>
If you prefer an automated approach or are running short on time, run one of the bootstrap scripts. Both are idempotent — they reuse existing app registrations rather than creating duplicates, so it is safe to run them multiple times.
PowerShell (Windows / cross-platform pwsh, recommended):
# Sign in to the tenant where the apps should live
az login --tenant <tenantId>
.\scripts\setup-entra-apps.ps1 `
-SpaName "Evidence Portal SPA" `
-ApiName "Evidence Portal API"This single command performs every step in this exercise via Microsoft Graph:
- Creates the API app and exposes the
Evidence.ReadOAuth2 scope. - Defines the
CaseReaderandCaseAdminapp roles. - Creates the SPA app and configures its
http://localhost:4200SPA redirect URI. - Grants the SPA delegated
Evidence.Readpermission and pre-authorizes it on the API. - Creates service principals for both apps.
- Grants tenant admin consent for the SPA's delegated permission.
- Self-assigns the signed-in user to both
CaseReaderandCaseAdmin. - Patches
environment.ts,environment.prod.ts, andapplication.propertieswith the resulting client/tenant IDs.
When the script finishes, you can jump directly to Exercise 2. Re-running the script later (for example with -ProductionRedirectUri https://my-spa.azurewebsites.net after Exercise 4) only adds the missing pieces.
Bash (macOS / Linux):
cd scripts
chmod +x setup-entra-apps.sh
./setup-entra-apps.shThe bash version covers the same Phase 1 surface (app registrations, scope, roles, redirect URI). For the consent + role-assignment automation in a single command, use the PowerShell version.
Confirm your setup by checking these items:
- API app registration exists with
Evidence.Readscope exposed -
CaseReaderandCaseAdminapp roles are created and enabled - SPA app registration exists with
http://localhost:4200as the redirect URI - SPA has
Evidence.Readdelegated permission granted - SPA is pre-authorized on the API
-
environment.tscontains real Client ID, Tenant ID, and scope URI - You have recorded the API Client ID, SPA Client ID, and Tenant ID for later exercises
| Problem | Cause | Fix |
|---|---|---|
| "Insufficient privileges" when creating registrations | Your account lacks the Application Developer role | Ask the workshop instructor to assign the role or create the registration for you |
| Scope not visible under "My APIs" | The API registration does not have an Application ID URI set | Go to Expose an API and add the Application ID URI first |
| "AADSTS650053" error on sign-in | Admin consent not granted for the delegated permission | Grant admin consent in the SPA's API permissions page |
| Wrong account type selected | Chose "Personal Microsoft accounts" instead of single tenant | Delete the registration and recreate with the correct account type |