agentleFS
MicrosoftKnown publishermicrosoft/b2c-hsc-native-auth-configuration/.github/copilot-instructions.md

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
  1. Distinctive:

    After enabling HSC mode, wait up to 1 hour for propagation

    line 50
  2. Distinctive:

    Always run from the repo root directory

    line 54
  3. Very specific:

    If env vars aren't set, the user needs to run 1-admin-setup.ps1 first

    line 55

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

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-end
  • 1-admin-setup/1-admin-setup.ps1 — Device code flow → sets delegated token env vars
  • 2-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 mode
  • 2-hsc-setup/3-hsc-enable-email-otp.ps1 — Enable Email OTP
  • 2-hsc-setup/4-hsc-check-status.ps1 — Check HSC + Email OTP status
  • 2-hsc-setup/5-hsc-disable.ps1 — Disable HSC mode
  • 3-native-auth-setup/1-native-auth-register-app.ps1 — Register native auth app + SP + flow
  • 3-native-auth-setup/2-native-auth-create-flow.ps1 — Create user flow separately
  • 3-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 VariableSet ByUsed By
HSC_TENANT_ID1-admin-setup.ps1Steps 2-4
HSC_ACCESS_TOKEN1-admin-setup.ps1Steps 2-3 (auto-refreshed)
HSC_REFRESH_TOKEN1-admin-setup.ps1Steps 2-3 (for token renewal)
HSC_NATIVE_APP_ID1-native-auth-register-app.ps1Steps 4-5
HSC_TENANT_NAME1-native-auth-register-app.ps1Step 5

Execution Order

  1. .\1-admin-setup\1-admin-setup.ps1 -TenantId "<TENANT_ID>"
  2. .\2-hsc-setup\1-hsc-preflight-check.ps1
  3. .\2-hsc-setup\2-hsc-enable.ps1
  4. .\2-hsc-setup\3-hsc-enable-email-otp.ps1
  5. .\3-native-auth-setup\1-native-auth-register-app.ps1 -AppName "NativeAuthApp" -CreateFlow
  6. .\3-native-auth-setup\3-native-auth-validate.ps1
  7. .\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)
  • $filter and $select don'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 oauth2PermissionGrants POST (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.ps1 first
  • Tokens auto-refresh when near expiry — no manual re-auth needed within a session
  • The -AutoFix flag on preflight check fixes empty custom attribute descriptions automatically
  • The user needs Global Administrator or Application Administrator role
  • 1-admin-setup.ps1 uses 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

ErrorFix
Authorization_RequestDeniedRe-run Step 1 or grant permissions manually
AADB2C99089Run 1-hsc-preflight-check.ps1 -AutoFix
HybridUpgradeNotAllowedTenant not allow-listed — contact Microsoft Support
consent_required on signupAdmin consent not granted — re-run 1-native-auth-register-app.ps1

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.