Skip to content

Add device-code auth fallback to Connect-FabricAccount - #201

Open
Theragus wants to merge 1 commit into
dataplat:developfrom
Theragus:feature/terminal-device-code-fallback
Open

Add device-code auth fallback to Connect-FabricAccount#201
Theragus wants to merge 1 commit into
dataplat:developfrom
Theragus:feature/terminal-device-code-fallback

Conversation

@Theragus

Copy link
Copy Markdown

Pull Request

Pull Request (PR) description

Connect-FabricAccount can fail silently in some terminal hosts when interactive/broker (WAM) sign-in can't display its account picker — e.g. Warp on Windows, which doesn't expose a window handle for WAM to parent its UI to. Connect-AzAccount throws instead of showing anything, and that failure previously propagated straight out of Connect-FabricAccount with no recovery path.

This PR adds an automatic fallback to device code authentication when the interactive sign-in attempt fails, plus a -UseDeviceAuthentication switch for explicit opt-in.

No related issue is linked — the underlying WAM failure turned out to be intermittent/hard to reproduce on demand across different terminal hosts (Warp, Git Bash/mintty both completed sign-in fine via Az.Accounts' own browser fallback once retried), so this is a proactive resiliency fix rather than a direct fix for a filed bug.

Added

  • Added -UseDeviceAuthentication switch to Connect-FabricAccount to force device code authentication instead of the interactive broker/browser flow

Fixed

  • Connect-FabricAccount now automatically falls back to device code authentication when interactive/broker (WAM) sign-in fails, e.g. in terminal hosts such as Warp on Windows where the account picker cannot render

Task list

  • The PR represents a single logical change. i.e. Cosmetic updates should go in different PRs.
  • Added an entry under the Unreleased section of in the CHANGELOG.md as per format.
  • Local clean build passes without issue or fail tests (build.ps1 -ResolveDependency -Tasks build, test).
  • Comment-based help added/updated.
  • Examples appropriately added/updated.
  • Unit tests added/updated..
  • Integration tests added/updated (where possible).
  • Documentation added/updated (where applicable).
  • Code follows the contribution guidelines.

Notes on unchecked items

  • Local clean build/test: Invoke-Pester ./tests/Unit/Connect-FabricAccount.Tests.ps1 passes 10/10 against the built module. I did not check this box because the full suite (./build.ps1 -Tasks build,test) has pre-existing failures unrelated to this change: Integration tests require a live Fabric session/capacity (not available in this environment), and Get-FabricWorkspaceUser.Tests.ps1 has a pre-existing mandatory-parameter mismatch unrelated to this PR.
  • Integration tests: not added — this change only affects the interactive auth failure/retry path, which isn't practical to exercise as a non-interactive integration test.
  • Documentation: docs/en-US/Connect-FabricAccount.md was intentionally left untouched. ./build.ps1 -Tasks Generate_help_from_built_module in my environment picks up a pre-installed higher-version copy of FabricTools instead of the local build, which produces an unrelated repo-wide diff across all cmdlets' docs instead of just this one. Happy to add a manually-written doc update for just Connect-FabricAccount if maintainers would like one included before merge.

When interactive/broker (WAM) sign-in fails, e.g. because a
terminal host (Warp on Windows was the reported case) can't
provide WAM a window handle to parent its account picker to,
Connect-AzAccount can throw instead of showing any UI, causing
Connect-FabricAccount to fail silently.

Wrap the interactive sign-in call in try/catch and retry with
Connect-AzAccount -UseDeviceAuthentication on failure, so users
get a usable device-code prompt instead of a hard failure. Also
add a -UseDeviceAuthentication switch for explicit opt-in.

Thanks for taking a look!

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Theragus Theragus changed the title Feature/terminal device code fallback Add device-code auth fallback to Connect-FabricAccount Aug 23, 2026
@Theragus
Theragus changed the base branch from main to develop August 23, 2026 10:07
@Theragus Theragus closed this Aug 23, 2026
@Theragus Theragus reopened this Aug 23, 2026
@NowinskiK

Copy link
Copy Markdown
Collaborator

Thanks for your contribution, @Theragus. Please look at the build errors and fix them if you can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants