How to switch accounts via VS Code Azure Account Extension

I've signed into one of my Azure accounts with Azure Account Extension via VS Code. I didn't find any button to sign out or switch accounts. How do I sign out or switch accounts?

49388 次浏览

There is no button that you can find to sign in or sign out in VS Code with Azure Account Extension. The extension works with commands from Command Palette.

enter image description here

In VS Code press Ctrl+Shift+p to see the command palette and write the symbol >, after that you can see any command you need including the sign out command to work with this extension.

Use the shortcut Ctrl + Shift + P to bring up VS Code command palette

In the command palette prompt that appears type:

Azure: Sign Out

The shortest way to achieve this in vscode is by pressing F1 to show the command pallet and then type azso (Azure Sign Out), first letter of each word, and press enter.

Note that this "first letter of each word" also works with other commands, very handy if you're a keyboard/shortcut person.

I had the same issue that I resolved as follows. There may be better ways of doing it. I just tried this work around to see if it works - and it did for me:

  1. Use Azure CLI to sign in via the PowerShell (I have latest version 7.3) using PS ...> az login

  2. In the same PowerShell Window, set your desired subscription as follows:

    PS ...> az account set --subscription 'Your subscription name or Id'

  3. In VSCode, in any of the Azure task window, place your mouse over the task window (e.g. Static Web Apps window) label and click on the refresh icon as shown below. This will show list of all your subscriptions (I have two subscriptions shown below). Select your desired subscription.

enter image description here