Sign in to Azure using different accounts from Visual Studio Code

  • Sandro Pereira
  • Jul 7, 2022
  • 4 min read

When we work inside an organization, this usually isn’t a problem. We develop solutions for the same company and typically use a single corporate account. In most cases, we sign in to Azure through the Azure Portal in the browser. If we use Microsoft Edge, Visual Studio Code automatically picks up that session. Otherwise, it prompts us to authenticate.

unique account

You can log off and log in again without any issues. It will likely not ask you to select an account or enter a password for a while.

But that will be a very different story when you are a consultant working with several clients across different account types. Fortunately, and unfortunately, this is my case! And to be completely honest, I’m not a big fan of Visual Studio Code to doing enterprise projects. I find it quite interesting to serve as a lightweight and quick code editor to do small things or inspect some code, but it is not exactly my favorite tool for creating complex and real projects.

📝 One-Minute Brief

A practical guide that explains how to sign out of Azure in VS Code and log in using a different account—especially useful when working with multiple clients or tenants. It walks through the quirks of the Azure extensions, why VS Code keeps reusing the previous account, and the exact steps needed to fully sign out and authenticate with another Azure identity.

My first problem started because I was already logged in on Azure using my company Account as you can see in the picture below:

Logic App Standard extention

So, the first question was: How to log off?

If you are not logged in, these Azure extensions have an easy option for you to log in:

Sign in to Azure

But if you are already logged in, you cannot find an easy, visible option to log off. Behavior that I find annoying. For me, the interfaces should be intuitive and easy to use, not spend hours figuring out how to perform basic tasks like logging in and out!

If you want to log off, you need to:

  • Invoke the VS Code commands palette by clicking CTRL+Shift+P.
  • And then type Azure sign out, and from the command list select Azure: Sign Out.
Sign Out.

And you will be signed off. Now, if you think that selecting once again the Sign in to Azure… option will do the trick and will ask you to choose the account to log in, think twice, because that will most probably present a page on Microsoft Edge saying:

Sign in info

And you will be signed in to the previous account you were signed in to before the logoff. You will confirm that behavior on the Visual Studio Code extension:

VS Code Sign in

Saying that, the magic question is: How the hell can you actually log off and log in using a different account?

It feels like a strange behavior, and for me, it is, but it is quite simple once you know it. Nevertheless, it requires many unnecessary manual steps. So, to actually log off in order for you to use a different account, you need to:

  • From VS Code, just like we did before, invoke the VS Code commands palette by clicking CTRL+Shift+P.
  • And then type Azure sign out, and from the command list select Azure: Sign Out.
Sign Out
  • Now, open Microsoft Edge and access the Azure Portal: https://portal.azure.com/.
  • You will see that you will already be logged in.
Azure Portal
  • In the top right corner, click on your user account and click Sign out.
Sign in
  • You can close the Microsoft Edge if you want and access our VS Code once again.
  • On VS Code, select the Sign in to Azure… option, and you will see that a new Microsoft Edge window will be opened, and this time asking you which account you want to use or to sign in using a different account:
Sign in

And that’s it!

Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son. 

Thanks for Buying me a coffe
Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

1 thought on “Sign in to Azure using different accounts from Visual Studio Code”

  1. Nah it still does not work properly. I have an AzureAD enabled Azure Stack Devkit (ASDK) install connected to my Azure subscription (its a requirement) on which I deployed App Services. So naturally I wanted VS Code to be able to connect to it. But what happens is that even if I am logging into Custom Cloud (not the default Azure Cloud) and selecting the subscription from there Azure plugin still retrieves my subscription from Azure Cloud and presents all the resources under that subscription. This clearly does not work properly.. Maybe the account information gets cached somewhere because uninstalling the Azure plugin and reinstalling it back still somehow finds the Azure Cloud subscription even if I did not logged in that account after I reinstalled the plugin.

Leave a Reply

Your email address will not be published. Required fields are marked *

The Ultimate Cloud
Management Platform for Azure

Supercharge your Azure Cost Saving

Learn More
Turbo360 Widget

Back to Top