Closed alexkyllo closed 4 years ago
Hi, If you still get the error. Please after option '-try_azcli_login' add option '-!se' it will generate a detailed error, including stack trace. Please copy the stack trace and send it to me. Michael
From: Alex Kyllo notifications@github.com Sent: Friday, August 14, 2020 6:30 PM To: microsoft/jupyter-Kqlmagic jupyter-Kqlmagic@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [microsoft/jupyter-Kqlmagic] azcli_login AuthenticationError (#60)
The azcli_login function doesn't seem to be working--when I run this:
%kql azureDataExplorer://code;cluster='mycluster';database='MyDatabase' -try_azcli_login
I get this error message, which doesn't help me figure out the problem:
AuthenticationError: AuthenticationError('azcli_login', 'TypeError('catching classes that do not inherit from BaseException is not allowed')', '{'authority': 'azcli_login', 'authentication_method': 'azcli_login', 'resource': 'https://mycluster.kusto.windows.net'}')
I'd really like to get azcli authentication working so I don't have to do a multi-step device code auth process every time I re-run my notebook. Any help would be much appreciated.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fjupyter-Kqlmagic%2Fissues%2F60&data=02%7C01%7Cmichabin%40microsoft.com%7C2616f1a4ba2a47cb085008d84066f4ae%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637330158226197200&sdata=wbl5E8ODGyHtkWTZcSuT1Bz5Y3K6blPY9GUt5w6LNgM%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACGKLXUJHZHHSZHQUL7HWBLSAVKAZANCNFSM4P7TQM3A&data=02%7C01%7Cmichabin%40microsoft.com%7C2616f1a4ba2a47cb085008d84066f4ae%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637330158226207192&sdata=%2FqOyaoo%2Fm6AsonA3cov%2F5HcS4tkKOt9KJ4JhdolJSuM%3D&reserved=0.
Looks like it's ModuleNotFoundError: No module named 'azure.common'
.
Could this be a transitive dependency that you're importing, which got removed from a recent release of a direct dependency package?
I installed Kqlmagic in a virtual environment before running this, and azure-common doesn't show up in the dependency graph.
Here's the requirements.txt I get after installing Kqlmagic in a fresh virtualenv, there's no azure-common
in the list:
adal==1.2.4
applicationinsights==0.11.9
appnope==0.1.0
argcomplete==1.12.0
azure-cli-core==2.10.1
azure-cli-nspkg==3.0.4
azure-cli-telemetry==1.0.4
azure-core==1.8.0
azure-mgmt-core==1.0.0
azure-mgmt-resource==10.1.0
azure-nspkg==3.0.2
backcall==0.2.0
bcrypt==3.2.0
beautifulsoup4==4.9.1
certifi==2020.6.20
cffi==1.14.2
chardet==3.0.4
click==7.1.2
colorama==0.4.3
cryptography==3.0
cycler==0.10.0
decorator==4.4.2
flask==1.1.2
humanfriendly==8.2
idna==2.10
ipykernel==5.3.4
ipython==7.17.0
ipython-genutils==0.2.0
isodate==0.6.0
itsdangerous==1.1.0
jedi==0.17.2
jinja2==2.11.2
jmespath==0.10.0
jupyter-client==6.1.6
jupyter-core==4.6.3
kiwisolver==1.2.0
knack==0.7.2
kqlmagic==0.1.113.post1
lxml==4.5.2
markdown==3.2.2
markupsafe==1.1.1
matplotlib==3.3.1
msrest==0.6.18
msrestazure==0.6.4
numpy==1.19.1
oauthlib==3.1.0
pandas==1.1.0
paramiko==2.7.1
parso==0.7.1
pexpect==4.8.0
pickleshare==0.7.5
pillow==7.2.0
pkginfo==1.5.0.1
plotly==4.9.0
prettytable==0.7.2
prompt-toolkit==3.0.6
psutil==5.7.2
ptyprocess==0.6.0
pycparser==2.20
pygments==2.6.1
pyjwt==1.7.1
pynacl==1.4.0
pyopenssl==19.1.0
pyparsing==2.4.7
pyperclip==1.8.0
pyreadline==2.1
python-dateutil==2.8.1
pytz==2020.1
pywin32==228
pyyaml==5.3.1
pyzmq==19.0.2
requests==2.24.0
requests-oauthlib==1.3.0
retrying==1.3.3
scipy==1.5.2
seaborn==0.10.1
six==1.15.0
soupsieve==1.9.6
tabulate==0.8.7
tornado==6.0.4
traitlets==4.3.3
urllib3==1.25.10
wcwidth==0.2.5
werkzeug==1.0.1
stack trace:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
~/.cache/pypoetry/virtualenvs/cosmosdb-retention--8NqaGzB-py3.8/lib/python3.8/site-packages/Kqlmagic/my_aad_helper.py in _get_azcli_token(self, subscription)
634 # from azure.cli.core._profile import _CLIENT_ID as AZCLI_CLIENT_ID
--> 635 from azure.common.credentials import get_cli_profile
636 try:
ModuleNotFoundError: No module named 'azure.common'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
~/.cache/pypoetry/virtualenvs/cosmosdb-retention--8NqaGzB-py3.8/lib/python3.8/site-packages/Kqlmagic/my_aad_helper.py in acquire_token(self)
221 if self._options.get("try_azcli_login"):
--> 222 token = self._get_azcli_token()
223 self._current_token = self._validate_and_refresh_token(token)
~/.cache/pypoetry/virtualenvs/cosmosdb-retention--8NqaGzB-py3.8/lib/python3.8/site-packages/Kqlmagic/my_aad_helper.py in _get_azcli_token(self, subscription)
641 pass
--> 642 except [ImportError, ModuleNotFoundError]:
643 raise AuthenticationError("Azure CLI authentication requires 'azure-cli-core' to be installed.")
TypeError: catching classes that do not inherit from BaseException is not allowed
During handling of the above exception, another exception occurred:
AuthenticationError Traceback (most recent call last)
<ipython-input-2-b2a998e65cbd> in <module>
----> 1 get_ipython().run_line_magic('kql', "azureDataExplorer://code;cluster='';database='' -try_azcli_login -!se")
~/.cache/pypoetry/virtualenvs/cosmosdb-retention--8NqaGzB-py3.8/lib/python3.8/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2324 kwargs['local_ns'] = self.get_local_scope(stack_depth)
2325 with self.builtin_trap:
-> 2326 result = fn(*args, **kwargs)
2327 return result
2328
<decorator-gen-127> in execute(self, line, cell, local_ns, override_vars, override_options, override_query_properties, override_connection, override_result_set)
~/.cache/pypoetry/virtualenvs/cosmosdb-retention--8NqaGzB-py3.8/lib/python3.8/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
<decorator-gen-126> in execute(self, line, cell, local_ns, override_vars, override_options, override_query_properties, override_connection, override_result_set)
~/.cache/pypoetry/virtualenvs/cosmosdb-retention--8NqaGzB-py3.8/lib/python3.8/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
~/.cache/pypoetry/virtualenvs/cosmosdb-retention--8NqaGzB-py3.8/lib/python3.8/site-packages/Kqlmagic/kql_magic.py in execute(self, line, cell, local_ns, override_vars, override_options, override_query_properties, override_connection, override_result_set)
663 #
664
--> 665 result = kql_core_obj.execute(
666 line=line,
667 cell=cell,
~/.cache/pypoetry/virtualenvs/cosmosdb-retention--8NqaGzB-py3.8/lib/python3.8/site-packages/Kqlmagic/kql_magic_core.py in execute(self, line, cell, local_ns, override_vars, override_options, override_query_properties, override_connection, override_result_set)
679
680 if command is None or command == "submit":
--> 681 result = self._execute_query(parsed, user_ns, result_set=override_result_set, override_vars=override_vars)
682 if type(result) == ResultSet:
683 # can't just return result as is, it fails when used with table package pandas_show_schema
~/.cache/pypoetry/virtualenvs/cosmosdb-retention--8NqaGzB-py3.8/lib/python3.8/site-packages/Kqlmagic/kql_magic_core.py in _execute_query(self, parsed, user_ns, result_set, override_vars)
1102 return None
1103 else:
-> 1104 raise e
1105
1106
~/.cache/pypoetry/virtualenvs/cosmosdb-retention--8NqaGzB-py3.8/lib/python3.8/site-packages/Kqlmagic/kql_magic_core.py in _execute_query(self, parsed, user_ns, result_set, override_vars)
929 retry_with_code = True
930 else:
--> 931 raise e
932
933 if retry_with_code:
~/.cache/pypoetry/virtualenvs/cosmosdb-retention--8NqaGzB-py3.8/lib/python3.8/site-packages/Kqlmagic/kql_magic_core.py in _execute_query(self, parsed, user_ns, result_set, override_vars)
921 retry_with_code = False
922 try:
--> 923 conn.validate(**options)
924 conn.set_validation_result(True)
925 except Exception as e:
~/.cache/pypoetry/virtualenvs/cosmosdb-retention--8NqaGzB-py3.8/lib/python3.8/site-packages/Kqlmagic/kql_engine.py in validate(self, **options)
155 raise KqlEngineError("Client is not defined.")
156 query = "range c from 1 to 10 step 1 | count"
--> 157 response = client.execute(self.get_database(), query, accept_partial_results=False, **options)
158 # print(f">>> json_response: {response.json_response}")
159 table = KqlResponse(response, **options).tables[0]
~/.cache/pypoetry/virtualenvs/cosmosdb-retention--8NqaGzB-py3.8/lib/python3.8/site-packages/Kqlmagic/kusto_client.py in execute(self, kusto_database, kusto_query, accept_partial_results, **options)
192 request_headers["x-ms-user"] = user_tag
193 if self._aad_helper is not None:
--> 194 request_headers["Authorization"] = self._aad_helper.acquire_token()
195 request_headers["Fed"] = "True"
196 # print("endpoint: ", endpoint)
~/.cache/pypoetry/virtualenvs/cosmosdb-retention--8NqaGzB-py3.8/lib/python3.8/site-packages/Kqlmagic/my_aad_helper.py in acquire_token(self)
399 except Exception as e:
400 kwargs = self._get_authentication_error_kwargs()
--> 401 raise AuthenticationError(e, **kwargs)
402
403
AuthenticationError: AuthenticationError('azcli_login', 'TypeError('catching classes that do not inherit from BaseException is not allowed')')
Now that azure-identity package is stable and has CLI support we should look at moving to that. I'm having problems even installing kqlmagic now because of msal dependency version conflicts as a result of kqlmagic pulling in azure-cli packages. azure-identity solves this problem by invoking the cli as a process. It does not depend on cli packages.
Cool, but in the meantime this ModuleNotFoundError can be fixed by a one-line addition to setup.py. Please see PR https://github.com/microsoft/jupyter-Kqlmagic/pull/61
azure-common will be included in setup.py in next version 0.1.114 use of azure-identity that will also allow single sign on with visual studio code will be included only in version 0.1.115
The azcli_login function doesn't seem to be working--when I run this:
%kql azureDataExplorer://code;cluster='mycluster';database='MyDatabase' -try_azcli_login
I get this error message, which doesn't help me figure out the problem:
AuthenticationError: AuthenticationError('azcli_login', 'TypeError('catching classes that do not inherit from BaseException is not allowed')', '{'authority': 'azcli_login', 'authentication_method': 'azcli_login', 'resource': 'https://mycluster.kusto.windows.net'}')
I'd really like to get azcli authentication working so I don't have to do a multi-step device code auth process every time I re-run my notebook. Any help would be much appreciated.