How to switch accounts via VS Code Azure Account Extension

AzureVisual Studio-Code

Azure Problem Overview


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?

Azure Solutions


Solution 1 - Azure

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.

Solution 2 - Azure

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

In the command palette prompt that appears type:

Azure: Sign Out

Solution 3 - Azure

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.

Solution 4 - Azure

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAndy LaiView Question on Stackoverflow
Solution 1 - AzureLlazarView Answer on Stackoverflow
Solution 2 - AzureMwizaView Answer on Stackoverflow
Solution 3 - AzureAdil H. RazaView Answer on Stackoverflow
Solution 4 - AzurenamView Answer on Stackoverflow