microsoft / jupyter-Kqlmagic

Extension (Magic) to Jupyter notebook and Jupyter lab, that enable notebook experience working with Kusto, ApplicationInsights, and LogAnalytics data.
Other
85 stars 31 forks source link

Unable to connect to Log Analytics using username/password #74

Closed Expecho closed 2 years ago

Expecho commented 3 years ago

So, according to the docs and example one should be able to connect using the username/password like this:

%kql loganalytics://username='<username>';password='<password>';workspace='<workspace-id>';alias='<workspace-friendly-name>'

But as soon as I try that I get the following error:

invalid connection string: loganalytics://username='xxx';password='yyy';workspace='zzz';alias='www', missing keys.

What is up with that?

mbnshtck commented 3 years ago

wasn't able to replicate the issue, works ok for me. Please send me what version of Kqlmagic you are using and log files (see instructions below) Possible reason you get this error:

You can enable logging by setting the LOG environment variables before you load Kqlmagic. The logs may provide insight why it fails: %env KQLMAGIC_LOG_LEVEL=DEBUG %env KQLMAGIC_LOG_LEVEL=

pls send me the log filename if you need more help on this

Expecho commented 3 years ago

I think I can reproduce the problem.

I am using Azure Data Studio notebook to query the data. Initially I tried to connect using %kql loganalytics://code;workspace='xxx';alias='yyy' but that fails:

KqlError: {"error":{"message":"The provided authentication is not valid for this resource","code":"InvalidTokenError","correlationId":"d76ff529-1b43-4122-aeae-6dbec9db5465","innererror":{"code":"InvalidAuthenticationTokenTenant","message":"The access token is from the wrong issuer '

Then I changed to

%kql loganalytics://username='<username>';password='<password>';workspace='<workspace-id>';alias='<workspace-friendly-name>'

Which gives an error

invalid connection string: loganalytics://username='xxx';password='yyy';workspace='zzz';alias='www', missing keys.

But when I close Azure Data Studio and reopen the notebook it works. It seems something goes wrong if you decide to change the way you authenticate while being in a single session.