Issue Type: Bug
Azure account shows error message:
Error: Failed to get credential for account

After refreshing account (browser opens, copying code, get confirmation) I can try again
Now I get an error in Linked Accounts pane:
You need to refresh the credentials for this account.

Can try over and over again.
Reinstalled application - no change
Azure Data Studio version: azuredatastudio 1.14.1 (f9b968c1ae514a0d1210788629e1c69125857279, 2019-12-24T02:42:26.303Z)
OS version: Windows_NT x64 10.0.18363
System Info
|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz (12 x 2208)|
|GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled|
|Load (avg)|undefined|
|Memory (System)|15.74GB (7.88GB free)|
|Process Argv||
|Screen Reader|no|
|VM|0%|
Extensions: none
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
Readding account as suggested in #8766 did not resolve issue
Same problem with insider build
Azure Data Studio version: azuredatastudio-insiders 1.15.0-insider (362af3c15347529196f5da4bfbdfe875dc8fbbc5, 2020-01-06T06:03:56.006Z)
OS version: Windows_NT x64 10.0.18363
System Info
|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz (12 x 2208)|
|GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off
surface_control: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off
webgl: enabled
webgl2: enabled|
|Load (avg)|undefined|
|Memory (System)|15.74GB (8.45GB free)|
|Process Argv||
|Screen Reader|no|
|VM|0%|
Extensions: none
Can you try https://github.com/microsoft/azuredatastudio/issues/7619#issuecomment-566231484
Can you try #7619 (comment)
not sure if I'm missing something but after clicking on Add an account a browser with the URL https://localhost:22209/signin?nonce=xxxxxx opens?
That's supposed to redirect to the microsoft authentication site. Is it just getting stuck on that page?
That's supposed to redirect to the microsoft authentication site. Is it just getting stuck on that page?
Yes, nothing else happening:

Why is it trying to open that page in https? That seems odd, do you have https everywhere configured? Or something to force https for localhost?
I got the new auth process to work.
After successful sign in I'm stuck in the same loop
@aaomidi do you have another idea?
Do you have any logs you can share from the developer console?
please have a look below:
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [createInstance] First service dependency of e at position 2 conflicts with 0 static arguments
console.<computed> @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [createInstance] First service dependency of e at position 3 conflicts with 0 static arguments
console.<computed> @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] Initialized Azure account extension storage.
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] logFile for MicrosoftSqlToolsServiceLayer.exe is c:\Users\{User}\AppData\Roaming\azuredatastudio\logs\20200114T072443\exthost1\Microsoft.mssql\sqltools.log
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] This process (ui Extenstion Host) is pid: 20612
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] Old log files deletion report: {}
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] logFile for MicrosoftSqlToolsCredentials.exe is c:\Users\{User}\AppData\Roaming\azuredatastudio\logs\20200114T072443\exthost1\Microsoft.mssql\credentialstore.log
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] This process (ui Extenstion Host) is pid: 20612
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] Old log files deletion report: {}
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] logFile for SqlToolsResourceProviderService.exe is c:\Users\{User}\AppData\Roaming\azuredatastudio\logs\20200114T072443\exthost1\Microsoft.mssql\resourceprovider.log
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] This process (ui Extenstion Host) is pid: 20612
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] Old log files deletion report: {}
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host]% null true
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host]% null true
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host]% null true
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] Refreshing account [object Object] failed - Error: Entry not found in cache.
console.<computed> @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] (node:20612) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
console.<computed> @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280
t.log @ workbench.desktop.main.js:385
$logExtensionHostMessage @ workbench.desktop.main.js:4295
_doInvokeHandler @ workbench.desktop.main.js:4301
_invokeHandler @ workbench.desktop.main.js:4301
_receiveRequest @ workbench.desktop.main.js:4300
_receiveOneMessage @ workbench.desktop.main.js:4299
(anonymous) @ workbench.desktop.main.js:4297
fire @ workbench.desktop.main.js:196
fire @ workbench.desktop.main.js:527
_receiveMessage @ workbench.desktop.main.js:532
(anonymous) @ workbench.desktop.main.js:529
fire @ workbench.desktop.main.js:196
acceptChunk @ workbench.desktop.main.js:525
(anonymous) @ workbench.desktop.main.js:524
t @ workbench.desktop.main.js:535
ZoneDelegate.invokeTask @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:421
Zone.runTask @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:188
ZoneTask.invokeTask @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:496
ZoneTask.invoke @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:485
emit @ events.js:200
addChunk @ _stream_readable.js:294
readableAddChunk @ _stream_readable.js:275
Readable.push @ _stream_readable.js:210
onStreamRead @ internal/stream_base_commons.js:166
c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280 [Extension Host] (node:20612) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
console.<computed> @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:2280
t.log @ workbench.desktop.main.js:385
$logExtensionHostMessage @ workbench.desktop.main.js:4295
_doInvokeHandler @ workbench.desktop.main.js:4301
_invokeHandler @ workbench.desktop.main.js:4301
_receiveRequest @ workbench.desktop.main.js:4300
_receiveOneMessage @ workbench.desktop.main.js:4299
(anonymous) @ workbench.desktop.main.js:4297
fire @ workbench.desktop.main.js:196
fire @ workbench.desktop.main.js:527
_receiveMessage @ workbench.desktop.main.js:532
(anonymous) @ workbench.desktop.main.js:529
fire @ workbench.desktop.main.js:196
acceptChunk @ workbench.desktop.main.js:525
(anonymous) @ workbench.desktop.main.js:524
t @ workbench.desktop.main.js:535
ZoneDelegate.invokeTask @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:421
Zone.runTask @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:188
ZoneTask.invokeTask @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:496
ZoneTask.invoke @ c:\Users\{User}\AppData\Local\Programs\Azure Data Studio\resources\app\node_modules.asar\zone.js\dist\zone-node.js:485
emit @ events.js:200
addChunk @ _stream_readable.js:294
readableAddChunk @ _stream_readable.js:275
Readable.push @ _stream_readable.js:210
onStreamRead @ internal/stream_base_commons.js:166
I'm going to move this issue to march since I have been unable to repro this locally.
This is also happening to me. I add my Azure account, and the browser logs me in successfully. The account is added:



But when I try to expand my list of subscriptions, I'm told to refresh the account:


I do this, and the browser logs me in successfully. But the message about refreshing the account remains. I tried deleting/re-adding the Azure account and uninstalling/reinstalling Azure Data Studio, but the error remains. I can only reproduce this on Ubuntu 16.04 Linux. I'm able to add my Azure account using the same Azure Data Studio build/commit on Windows. Let me know if there is any other information I can share.
Version: 1.15.0-insider
Commit: 343daf58fef1a5b08c37efb33e04ec3ef08e3875
Date: 2020-02-06T05:32:20.142Z
VS Code: 1.42.0
Electron: 6.1.6
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Linux x64 4.15.0-76-generic
I will test this ASAP on Linux. There shouldn't be a big difference in how it works, so that's definitely weird.
Are there any errors on the developer log? Help -> Toggle Developer Tools?
No errors in this log. This is the only entry after going through all the steps:

Interesting, thank you! I'll check on it asap.
I attached a debugger to the latest commit eeae87ea3259b510bab9de685b859c83cf1a831b and see the following error:
message:"Entry not found in cache."
stack:"Error: Entry not found in cache.
at Logger.createError (/home/brian/azuredatastudio/extensions/azurecore/node_modules/adal-node/lib/log.js:216:13)
at TokenRequest.<anonymous> (/home/brian/azuredatastudio/extensions/azurecore/node_modules/adal-node/lib/token-request.js:526:40)
at /home/brian/azuredatastudio/extensions/azurecore/node_modules/adal-node/lib/token-request.js:148:20
at /home/brian/azuredatastudio/extensions/azurecore/node_modules/adal-node/lib/cache-driver.js:366:7
at /home/brian/azuredatastudio/extensions/azurecore/node_modules/adal-node/lib/cache-driver.js:301:7
at Request._callback (/home/brian/azuredatastudio/extensions/azurecore/node_modules/adal-node/lib/util.js:130:7)
at Request.callback (/home/brian/azuredatastudio/extensions/azurecore/node_modules/request/request.js:185:22)
at Request.emit (events.js:203:13)
at Request.<anonymous> (/home/brian/azuredatastudio/extensions/azurecore/node_modules/request/request.js:1161:10)
at Request.emit (events.js:203:13)
at IncomingMessage.<ano...
It's thrown by this line with the breakpoint:

Hi, unfortunately this is an issue with the adal-node library :( We're in the process of updating our authentication scheme https://github.com/microsoft/azuredatastudio/pull/9141.
In the meantime you can enable device login https://github.com/microsoft/azuredatastudio/issues/9147#issuecomment-586408376
We've hit some delays with the update to MSAL, hopefully April is an achievable goal.
This should be fixed in the latest insiders.
I'm still seeing issues that seem related to this - no matter how I try to refresh/remove/readd my account, I consistently get "Failed to get Azure account token for connection" when I try to log in. This is with the latest insiders build:
Version Info
Version: 1.20.0-insider
Commit: 2d989e1180f342d684a4e26f76b941843b7fc261
Date: 2020-07-03T05:33:54.074Z
VS Code: 1.46.0
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.5.0
It looks like I'm hitting the condition created by https://github.com/microsoft/azuredatastudio/pull/9921:
[Extension Host] Could not refresh access token for {"id":"a78ab2cf-2bda-4133-a498-7a09555496bd","displayName":"<tenant>","userId":"kevin@<tenant_domain>","tenantCategory":"Home"} - silently removing the tenant from the user's account. (at d.getSecurityToken (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:16:126481))
/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/node_modules.asar/zone.js/dist/zone-node.js:2280 INFO No security tokens found for account
/Applications/Azure Data Studio - Insiders.app/Contents/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 (connectionManagementService.ts:474) [<root>]
at processTicksAndRejections (internal/process/task_queues.js:85) [<root>]
at async k.handleDefaultOnConnect (connectionDialogService.ts:254) [<root>]
I've verified that I can actually perform DB operations in the portal, and this has worked in the past.
On application launch, I get the error: Error when adding your account to the cache. from the "Azure (Core) (Extension)"
Possibly interesting, the AAD tenant backing my subscription is set up with G suite as the IdP for AAD as described here: https://github.com/IAmFrench/GSuite-as-identity-Provider-IdP-for-Office-365-or-Azure-Active-Directory
Let me know if I should open a new issue for this or how I can help debug.
I'm guessing that GSuite being the IdP is probably part of the issue. I'm making a new PR https://github.com/microsoft/azuredatastudio/pull/11208 to give us some more context on what the error was.
Once it's merged, tomorrows insider build should have the latest changes. If this is urgent, you can build from source and test that way as well. (https://github.com/microsoft/azuredatastudio/wiki/Developer-Getting-Started-Guide)
Tested out the new insider build today. Here's my console output from today's attempt:
[Extension Host] Error: Error when adding your account to the cache. at d.setCachedToken (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:16:131174) at d.refreshAccessToken (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:16:130991) at processTicksAndRejections (internal/process/task_queues.js:85:5) at async d.refreshAccess (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:16:125411) at async u._initialize (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:166:32430) (at d.refreshAccess (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:16:125700))
/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/node_modules.asar/zone.js/dist/zone-node.js:2280 [Extension Host] Could not refresh access token for {"id":"a78ab2cf-2bda-4133-a498-7a09555496bd","displayName":"<tenant>","userId":"kevin@<tenant_domain>.org","tenantCategory":"Home"} - silently removing the tenant from the user's account. (at d.getSecurityToken (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:16:126491))
/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/node_modules.asar/zone.js/dist/zone-node.js:2280 [Extension Host] Actual error: "Error when adding your account to the cache." (at d.getSecurityToken (/Applications/Azure Data Studio - Insiders.app/Contents/Resources/app/extensions/azurecore/dist/extension.js:16:126618))
@kevin-david Settings -> Azure -> "No System Keychain" - is it checked or not?
You might want to disable the system keychain and try it again.
You may also have some interesting information on startup of the application.
@aaomidi sorry for the delay getting back to you. I installed the latest insiders build today and this appears to be fixed?
Working Version Info
Version: 1.21.0-insider
Commit: eccf3cf5fe8f60d04d70096bc94c654cab60d81a
Date: 2020-07-24T09:28:31.172Z
VS Code: 1.48.0
Electron: 9.1.0
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 19.6.0
It doesn't work on the latest non-insiders build, as far as I can tell. Before I updated, I got an error I hadn't seen before: Error running command azure.resource.selectsubscriptions: Cannot set property 'isStale' of undefined. This is likely caused by the extension that contributes azure.resource.selectsubscriptions.
Hope this helps, and glad it seems to be working again!
Yep the fix is only in insiders right now. I'm glad to see it's working now!
I'll be closing this issue now - please test with the latest insiders and let me know if any issues pop up with this. If the issue is unrelated to this one please open a new one!
How do I get an insiders build?
https://github.com/microsoft/azuredatastudio#try-out-the-latest-insiders-build-from-main