b2c-hsc-native-auth-configuration
Copilot instructions1 starsChanged 8 months agoMITView on GitHub
This repo automates enabling HSC (High Scale Compatibility) mode on Azure AD B2C tenants and configuring Native Authentication APIs. Scripts propagate credentials automatically via env vars — no need to repeat params after Step 1: Or one-shot: .\run-all.ps1 -TenantId "<TENANT_ID>"
- Reads credentials
The file
We split this copilot-instructions.md into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 50
After enabling HSC mode, wait up to 1 hour for propagation
- Distinctive: line 54
Always run from the repo root directory
- Very specific: line 55
If env vars aren't set, the user needs to run 1-admin-setup.ps1 first
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
HSC Mode & Native Authentication — Copilot Context
This repo automates enabling HSC (High Scale Compatibility) mode on Azure AD B2C tenants and configuring Native Authentication APIs.
Repo Structure
run-all.ps1— One-shot: runs all steps end-to-end1-admin-setup/1-admin-setup.ps1— Device code flow → sets delegated token env vars2-hsc-setup/1-hsc-preflight-check.ps1— 4 preflight checks (tenant type, permissions, custom attrs, subscription)2-hsc-setup/2-hsc-enable.ps1— Enable HSC mode2-hsc-setup/3-hsc-enable-email-otp.ps1— Enable Email OTP2-hsc-setup/4-hsc-check-status.ps1— Check HSC + Email OTP status2-hsc-setup/5-hsc-disable.ps1— Disable HSC mode3-native-auth-setup/1-native-auth-register-app.ps1— Register native auth app + SP + flow3-native-auth-setup/2-native-auth-create-flow.ps1— Create user flow separately3-native-auth-setup/3-native-auth-validate.ps1— Validate full setup (4 checks)4-native-auth-flows/1-native-auth-signup.ps1— Sign-up (Email OTP)4-native-auth-flows/2-native-auth-signin.ps1— Sign-in (Email OTP)
Environment Variables
Scripts propagate credentials automatically via env vars — no need to repeat params after Step 1:
| Env Variable | Set By | Used By |
HSC_TENANT_ID | 1-admin-setup.ps1 | Steps 2-4 |
HSC_ACCESS_TOKEN | 1-admin-setup.ps1 | Steps 2-3 (auto-refreshed) |
HSC_REFRESH_TOKEN | 1-admin-setup.ps1 | Steps 2-3 (for token renewal) |
HSC_NATIVE_APP_ID | 1-native-auth-register-app.ps1 | Steps 4-5 |
HSC_TENANT_NAME | 1-native-auth-register-app.ps1 | Step 5 |
Execution Order
.\1-admin-setup\1-admin-setup.ps1 -TenantId "<TENANT_ID>".\2-hsc-setup\1-hsc-preflight-check.ps1.\2-hsc-setup\2-hsc-enable.ps1.\2-hsc-setup\3-hsc-enable-email-otp.ps1.\3-native-auth-setup\1-native-auth-register-app.ps1 -AppName "NativeAuthApp" -CreateFlow.\3-native-auth-setup\3-native-auth-validate.ps1.\4-native-auth-flows\1-native-auth-signup.ps1 -Email "user@example.com"
Or one-shot: .\run-all.ps1 -TenantId "<TENANT_ID>"
Key Technical Details
- Graph API beta is required for
authenticationEventsFlows(v1.0 not supported on B2C) $filterand$selectdon't work on beta authenticationEventsFlows — list all + filter in memory- SP creation after app registration has replication lag — scripts use retry with backoff
- Admin consent is granted via
oauth2PermissionGrantsPOST (SP-scoped endpoint) - After enabling HSC mode, wait up to 1 hour for propagation
When Running Scripts
- Always run from the repo root directory
- If env vars aren't set, the user needs to run
1-admin-setup.ps1first - Tokens auto-refresh when near expiry — no manual re-auth needed within a session
- The
-AutoFixflag on preflight check fixes empty custom attribute descriptions automatically - The user needs Global Administrator or Application Administrator role
1-admin-setup.ps1uses device code flow — it prints a URL and a code, then blocks waiting for the user to authenticate in a browser. Always run it in async mode (or with a long timeout) so the user has time to complete the browser login. After launching, read the terminal output to extract the URL and device code, then present them directly in the chat message so the user can click/copy without switching to the terminal. Wait for the script to finish before proceeding to step 2.
Common Errors
| Error | Fix |
Authorization_RequestDenied | Re-run Step 1 or grant permissions manually |
AADB2C99089 | Run 1-hsc-preflight-check.ps1 -AutoFix |
HybridUpgradeNotAllowed | Tenant not allow-listed — contact Microsoft Support |
consent_required on signup | Admin consent not granted — re-run 1-native-auth-register-app.ps1 |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

