microsoft / AzureDatalakeToolsForVSCode

Azure Datalake Tools For VSCode
Other
10 stars 13 forks source link

Cannot see my ADL accounts #11

Closed osmant closed 6 years ago

osmant commented 6 years ago

Hi,

I am having problems when trying to connect Azure Data Lake and see my ADL accounts. Let me explain what I do and what happens after all.

  1. Open command pallet, then click ADL:Login option.
  2. Logging in from Azure portal using generated code in VSCode
  3. In VsCode, opening command pallate and calling ADL:ListAccounts

This command is returning me following message

[Info] Start listing Data Lake Analytics accounts...
[Info] 

Then nothing is listed. Normally I would expect Azure Data Analytics account to be listed there. Not only this command was failing, Data Lake Explorer was showing my subscription fine but when I want to see the ADLA account, it was not working. Also I can not submit/compile any usql file.

At this point what I did is, as mostly suggested, I looked at the Developer tools. In developer tools I found a error message as following.

image

As indicated in the error message, I found the authenticationManager.js file in the path which error message is referring to and following method in the file.

updateDatalakeServiceCredentials() {
    if (AuthenticationManager.azureAccount.status == 'LoggedIn') {
        AuthenticationManager.azureAccount.sessions.forEach(session => {
            let tokens = session.credentials["tokenCache"]._entries;
            let token = tokens.find(t => t.tenantId == session.tenantId);
            console.log(`updateDatalakeServiceCredentials ${session.tenantId}, ${token.accessToken}`);
            this.logger.debug(`updateDatalakeServiceCredentials ${session.tenantId}, ${token.accessToken}`
            this.credentialAdd(session.tenantId, token.accessToken);
        });
    }
}

It was not super easy to debug this method, but with a lot of console.log(object), I got to know that following lines is the one causing an exception.

let tokens = session.credentials["tokenCache"]._entries;
let token = tokens.find(t => t.tenantId == session.tenantId);

in the first method tokens is being assigned to null and therefore find function throws an error.

The reason why tokens is being null is because session.credentials["tokenCache"] object does not have property _entries

When I log the session.credentials["tokenCache"] to console, I noticed that expected _entries array is not there. In fact, _entries array is beneath target property. Please check following screenshot.

image

Hence the code was throwing an exception. I don't know whether this is general bug or not. But once I changed all session.credentials["tokenCache"]._entries; into session.credentials["tokenCache"].target._entries;

Everything started to work as expected. It was tedious problem because suddenly my development environment stopped working. I just wanted to share in case if it requires any action from on developer of this add-in.

Regards

tigerenwork commented 6 years ago

Hi osmant, Thanks a lot for your analysis!

You are right, this is an issue caused by the changes of Azure Account extension which we depends on. The week before last week Azure Account upgraded to 0.3.0, in which version the credential _entries was moved into target property, which breaks our authentication module.

We released a new version(0.2.9) last week and fixed the issue, could you please try the new one? We highly appreciate your detailed analysis on this issue.

Thanks, Tiger

osmant commented 6 years ago

Hi @tigerenwork,

Thanks for the update. I have just upgraded the extension to v 0.2.9 and it started to work.

Regards