
Steps to Reproduce:
1.Try to Sign in to Azure



Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
Hey @waldyd, could you please see if adding an account works on the latest insiders build?
https://github.com/microsoft/azuredatastudio#try-out-the-latest-insiders-build-from-master
Yes @aaomidi . It is working for the Latest Windows User Insider version.
Thanks! Then this problem should be fixed for next release.
@aaomidi but when trying to connect. This was prompted:

Hmm, that's weird. Does it repro 100% of the time?
Any errors in the developer console?
Help -> Toggle Developer Tools
Yes. It was reproduced several times.
Here the developer console errors are:
```
Getting key failed: Error: A specified logon session does not exist. It may already have been terminated.
(at t.SimpleTokenCache.
2c:\Users\nalvarez\AppData\Local\Programs\Azure Data Studio - Insiders\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280
[Extension Host] (node:17540) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. (at writeOut (internal/process/warning.js:27:3))
Adding key failed: Error: A specified logon session does not exist. It may already have been terminated.
(at t.SimpleTokenCache.
2c:\Users\nalvarez\AppData\Local\Programs\Azure Data Studio - Insiders\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280
[Extension Host] Getting key failed: Error: A specified logon session does not exist. It may already have been terminated.
(at t.SimpleTokenCache.
c:\Users\nalvarez\AppData\Local\Programs\Azure Data Studio - Insiders\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280
ERR Error: Failed to get Azure account token for connection
at e.connectWithOptions (workbench.desktop.main.js:5617) [
at processTicksAndRejections (internal/process/task_queues.js:85) [
at async e.handleDefaultOnConnect (workbench.desktop.main.js:7773) [
[Extension Host] Shutting off webserver... (at Timeout._onTimeout (c:\Users\nalvarez\AppData\Local\Programs\Azure Data Studio - Insiders\resources\app\extensions\azurecore\dist\extension.js:166:68580))
````
Then while trying to refresh the credentials:
c:\Users\nalvarez\AppData\Local\Programs\Azure Data Studio - Insiders\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 ERR Error while refreshing account: TypeError: Cannot read property '2c94bed6-d675-4d3d-a53b-7b461fd6acc2' of undefined
I am getting the sate issue in insiders build on Mac OSX.

After adding the account I get the following error message, and no account is added

In the console I get

Thank you this is extremely useful to investigate.
@waldyd It seems like your issue is something to do with how your windows is setup. Azure Data Studio uses Windows Credential Manager to store authentication tokens.

This is technically the expected/secure way for us to store authentication tokens.
I think there is an argument to be made for us to enable flat-file storage for users like yourself that may have a stricter domain configuration, but I'm not entirely sure if that's wise as these tokens essentially identify you to the Azure service.
I recommend looking up the error you've received "A specified logon session does not exist. It may already have been terminated & Credential Manager", and you'll find a few threads that talk about that same issue.
If you look at your Local Group Policy Editor (Win+R, gpedit.msc) the following setting might be switched on to "Enabled":

This is likely blocking ADS to store credentials there.
Hi @aaomidi . That policy was disabled in my case:


Also, in my case, the browser is managed by my organization
@waldyd If it's enabled it wouldn't work I think. Can you try to use ADS on another device and see if you can repro this?
@magnusbratt We've published a new insiders build with more debug output, can you try to add your account on the latest version of ADS insiders?
The developer logs should contain a lot more info.
OK. I updated to the lastest Insider version. I added my Azure account, and get the web page sign in. Then I get this error message in ADS:

and this in the developer tools console

I now also installed the Insiders build on a Windows PC. When signing into Azure, I got

I then get the same

and in the developer tools console

So it seems you belong to a tenant where you don't actually have permissions to do resource management on it.
I'll make a PR that silently ignores tenants where you don't have permissions to do operations on them. Hopefully that fixes your problem.
It'll also contain some more debug information giving you information on why that's failing.
Can you check on azure portal to see if you have permissions to the tenant described by:

My account does belong to a few directories where I do not have permissions. However, for the directory referenced, I am "global administrator".

However, I removed "left the organization" for another tenant that I know I do not have permissions to. After this, I was able to expand my subscriptions and access resources. But when I try to expand a database to view it, it does not expand. The spinner never stops, se screenshot. There are no additional messages in the developer tools console.

Whoops didn't mean to close this issue. Let's wait for the insiders build tomorrow and go over this. Thank you so much for helping me debug this @magnusbratt :)
Just FYI. I just updated to the latest Insider build and the issue persists.

I get no new messages in developer tools console.
Could you please share your console either way? Would still be helpful :)
Here is a screenshot, including developer tools console

Oh so it lists the databases, just doesn't connect to them right?
Correct. That's a new behavior since after I left the tenant for which I did not have permissions. That is, I can expand the account, the subscription, "SQL database", but not view the database.
I can also expand the account, the subscription, "SQL server", but not view/expand the server.

@magnusbratt Alright that's a whole different issue. Could you try making yourself the admin on that server on azure portal.
Open the SQL Database on Azure Portal, and add your account as the Active Directory admin.

@aaomidi Is it OK to continue in this thread, or do you want me to create a new issue?
I am already a member of the Active Directory group that is admin of the server.


@aaomidi FYI: Today I updated ADZ Insiders on my Mac and it now works to sign in with my AAD account and access the database servers and databases I have access to.
It still does not work with the non-insider build, but I assume that is a matter of time.
I have also tested the latest insiders build on my PC and it works just as well.
Thanks for developing great software!
This is still an issue for me with Azure Insiders 1.18.0 build.
Trying to connect to postgres.
ERR Error: Failed to get Azure account token for connection
at e.connectWithOptions (workbench.desktop.main.js:5724) [
at async e.handleDefaultOnConnect (workbench.desktop.main.js:7901) [
Insiders is unfortunately a little broken at the moment. I would suggest sticking to the release branch.
If this issue is specific to PostgreSQL, I would recommend opening another issue.
Wasn't working in release which is why I tried insiders.
So since the original issue is fixed, I'll be closing this issue.
Please definitely open a new issue if you are seeing any issues with AzureMFA.