-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
az login unexpected error: invalid argument #28156
Comments
Thank you for opening this issue, we will look into it. |
I am also not able to repro this
@r0dg3rd0dg3r, could you try the above commands and check the output? You need to run @rayluo, by any chance you have encountered this issue before? |
@r0dg3rd0dg3r , how do you reproduce this error? I do not remember encountering |
In my opinion, if |
PS C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2> python
|
Empirically, encryption (DPAPI) could raise some weird errors and we never really know why. There are multiple issues reported before in Azure CLI issues, although not necessarily this Regardless, we can't really investigate without a reproduce. |
Any recommendation of what to try next? |
Running this command seems to have gotten me past it, but I don't know why. |
Interesting. The last line in log before that error was:
And that line 137 is here. Perhaps @r0dg3rd0dg3r can manually run that line on your file, for example, python -c "import os; os.open('C:\\Users\\rsmith\\.azure\\msal_token_cache.bin', os.O_RDWR | os.O_CREAT | os.O_TRUNC, 0o600)" And perhaps that can "reproduce" the error in your current environment. Next, you may try renaming your existing problematic file into a different name, and then re-enable the encryption, and see if Azure CLI will generate a new file and work fine. If you can reach that far, you may then somehow compare the old and new files and see what their difference is. Could it be the old file's handler somehow being occupied? Could it recover after a reboot? Anyway, I'm just guessing at this point... |
@r0dg3rd0dg3r, this is not executing the
@r0dg3rd0dg3r, this will make Azure CLI use
@rayluo, as you pointed out later, it hasn't reached DPAPI yet. It is merely an |
I don't know whether a previous unsuccessful operation (stuck in a DPAPI call?) would cause the file handler still being "occupied". So, in my last message, I suggested @r0dg3rd0dg3r to run some tests to see whether the existing "msal_token_cache.bin" file can be opened. If that |
Describe the bug
We normally use az login before locally debugging microservices that use DefaultAzureCredential to fetch a token via Azure AD. As of a few days ago, attempting az lo az logingin from the command terminal results in an unexpected error.
Related command
az login
Errors
A web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with
az login --use-device-code
.The command failed with an unexpected error. Here is the traceback:
[Errno 22] Invalid argument: 'C:\Users\rsmith\.azure\msal_token_cache.bin'
Traceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 663, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 726, in _run_jobs_serially
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 697, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 333, in call
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/profile/custom.py", line 139, in login
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/_profile.py", line 154, in login
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/auth/identity.py", line 160, in login_with_auth_code
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal/application.py", line 1861, in acquire_token_interactive
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal/oauth2cli/oidc.py", line 281, in obtain_token_by_browser
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal/oauth2cli/oauth2.py", line 639, in obtain_token_by_browser
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal/oauth2cli/oauth2.py", line 677, in _obtain_token_by_browser
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal/application.py", line 153, in obtain_token_by_auth_code_flow
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal/oauth2cli/oidc.py", line 205, in obtain_token_by_auth_code_flow
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal/oauth2cli/oauth2.py", line 547, in obtain_token_by_auth_code_flow
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal/oauth2cli/oauth2.py", line 731, in _obtain_token_by_authorization_code
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal/oauth2cli/oidc.py", line 116, in _obtain_token
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal/oauth2cli/oauth2.py", line 788, in _obtain_token
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal/application.py", line 707, in
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal/token_cache.py", line 317, in add
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal/token_cache.py", line 128, in add
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal/token_cache.py", line 247, in __add
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal_extensions/token_cache.py", line 69, in modify
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal_extensions/persistence.py", line 215, in save
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\msal_extensions/persistence.py", line 137, in _open
OSError: [Errno 22] Invalid argument: 'C:\Users\\.azure\msal_token_cache.bin'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
The text was updated successfully, but these errors were encountered: