feat(powershell): az CLI work/personal account switch (azw/azp) + prompt tag - #30
Merged
Conversation
Flip the Azure CLI between a work and personal account in a running shell without a new terminal or re-login. Each account gets an isolated az config dir via AZURE_CONFIG_DIR (asymmetric: work = default ~/.azure so the existing login is untouched; personal = ~/.azure-personal). The last-used choice persists to ~/.azure-active-profile and is restored in Phase 1 by the profile (a work/missing/unrecognized state actively unsets the var so an inherited value can't leak in). Switching clears the session-cached ADO bearer token ($global:__AdoAccessToken) so prr/Invoke-AdoPrReview re-authenticates against the now-active account. The active account is always visible in the prompt (az:work / az:personal), driven by $env:AZURE_CONFIG_DIR alone — no az process. Covered by tests/AzCliAccount.Tests.ps1 and tests/Set-Prompt.Tests.ps1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
az(Azure CLI) work/personal account switching to the PowerShell profile — flip accounts in a running shell without a new terminal or re-login.Switch-AzWork/Switch-AzPersonal(+azw/azpaliases) in newpowershell/Profile/AzCliAccount.ps1. Each account isolates its token cache viaAZURE_CONFIG_DIR— asymmetric on purpose: work = default~/.azure(existing login untouched), personal =~/.azure-personal.~/.azure-active-profile; restored in Phase 1. Awork/missing/unrecognized state actively unsets the var so an inherited value can't leak.$global:__AdoAccessToken) soprr/Invoke-AdoPrReviewre-authenticates against the now-active account (deliberately not pinned — it follows whichever account owns the PRs).az:work(green) /az:personal(magenta) on the context line, driven by$env:AZURE_CONFIG_DIRalone — noazprocess.Tests / gates
22 Pester green (7
AzCliAccount.Tests.ps1+ 2 newSet-Promptsegment tests + existing); PSScriptAnalyzer-Recursegated-clean.Review
Cross-model Codex review run: 1 HIGH + 3 MEDIUM, all evaluated and declined with grounds (fail-open default-to-work is deliberate for a Phase-1 load path; repo convention types params not locals).
One-time setup
az loginper config dir is interactive. Work already lives in~/.azure; personal needs oneaz loginunderAZURE_CONFIG_DIR=~/.azure-personal.