Sign in to Azure using different accounts from Visual Studio Code

When we work inside an organization, this may not be a problem. We are developing solutions for our organization and probably using a unique account, our organization account. So, basically, we sign in on Azure using the Azure Portal thru the browser, and that will be reflected automatically in the Visual Studio Code if we have used Microsoft Edge, or it will be prompted:

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

But that will be a very different story when you are a consultant working with several clients using different types of accounts. Fortunately, and unfortunately, this is my case! And to be completely honest, I’m not a big fan of Visual Studio Code to do 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.

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

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:

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

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

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:

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

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 is quite simple once you know it. Nevertheless, it requires a lot of 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
  • Now, open the Microsoft Edge and access the Azure Portal: https://portal.azure.com/
  • You will see that you will be already logged in
  • On the top right corner, click on your user account and click Sign out.
  • You can close the Microsoft Edge if you want and access once again our VS Code
  • On the 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 what account you want to use or to sign in using a different account:

And that’s it!

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.

Leave a Reply

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

turbo360

Back to Top