microsoft / microsoft/fabric-cli

[FEATURE] Multi-account session management

Open
#206 4 comments 0 reactions 1 assignee View on GitHub

@HasanAboShally is already working on this.

Since Apr 12, 2026.

Dominant language
Python
Stars
173
Forks
63
Avg merge
2d 19h
Merged PRs (30d)
4

Description

Problem

Consultants and developers who work across multiple Microsoft Fabric tenants and client environments face a painful workflow today: every time they need to switch context, they must run fab auth logout followed by a full fab auth login, re-authenticating interactively each time.

Real-world use case

A typical consulting scenario:

  • Client A - Production tenant tenant-aaa, user consultant@clientA.com
  • Client B - Dev/test tenant tenant-bbb, user consultant@clientB.com
  • Internal - Corporate tenant tenant-ccc, user me@mycorp.com

Switching between these today requires a full logout/login cycle for each transition, which is disruptive, slow, and breaks automation scripts that assume a persistent session.

Proposed solution

Add stored user session management to the CLI so that multiple interactive authentication sessions can coexist and be switched instantly:

Command Description
fab auth list List all stored user sessions with active/valid status
fab auth switch Switch to another stored session (interactive or direct)
fab auth switch -u <account> -t <tenant> Switch directly to a specific account (case-insensitive)
fab auth logout -u <account> Log out a specific session without affecting others
fab auth logout --all Clear all stored sessions
Behavior
  • Two stored sessions, no flags: fab auth switch automatically toggles to the other account.
  • Three or more sessions, no flags: an interactive prompt is shown.
  • With -u (and optionally -t): switches directly, no prompt.
  • Sessions are validated against the MSAL token cache and marked as valid/invalid in fab auth list.
  • Environment variable authentication (FAB_TOKEN, etc.) takes precedence and blocks session switching with a clear error message.
  • Interactive login now preserves the broker-backed MSAL app across the Fabric, OneLake, and Azure token warm-up so newly selected accounts are stored cleanly on Windows.

Acceptance criteria

  • fab auth list shows all stored sessions with active/valid/last_used metadata
  • fab auth switch supports direct (-u, -t) and interactive selection
  • fab auth logout supports per-session removal (-u, -t) and bulk (--all)
  • Username matching is case-insensitive
  • Session switching is blocked when env var auth is active
  • Documentation and examples are up to date
  • Tests cover happy paths and edge cases

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.