-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
AssertionError importing from azure.identity in Azure Function #19989
Comments
There's also an old issue on pywin32. I assume you're running this function locally on Windows with the Azure Functions CLI. This error doesn't repro in my environment with a function that imports Here's mine for comparison:
|
We are having this same issue, and here is the azure-functions==1.7.2 |
Interesting, same version of the pertinent libraries. Which Python? I installed your libraries (plus azure-core 1.16.0) in my environment (Python 3.7.9) and still don't get the error. I should also add I'm using Azure Functions CLI 3.0.3477. |
3.9.2 64 bit Also, confirmed with co-worker that this is the line that is causing the error above. |
Do you see the same error in a fresh venv? I don't see it on 3.9 either. |
It did; we deleted and re-did the virutal environment. We were using the Azure Functions add-in for VSCode to create the boilerplate code for the function; not sure if that's the same as the CLI. Here is the code (can't post the rest of function, sorry!) which results in an error
Azure Functions Core Tools Python 3.9.2 64 bit, requirements.txt
|
I don't see this error on my machine with everything installed as you describe. I think fixing it will require understanding why, in your particular environment, |
Hi @chlowell I got a similar issue but I don't need to add any code. As soon I do this "cocktail" modules together, I will get a similar error message (not to say the same) Here some info of my conf:
I try to develop a Durable Function Here my requirements.txt
or "only"
To reproduce my env:
All good it works Then add this on your requirements.txt
Run debug again, it will run but with a bunch of warnings:
If on my requirements.txt, I put:
or
After recreating my .venv, I don't have any issue It is as soon as I put "azure-identity" and "azure-devops" together, it "corrupts" my virtual env Here my pip freeze (from my virtual env):
I tried a different version of "pywin32" (300, 228) I got the same issue. I tried on Windows Subsystem Linux and I don't get any issue to debug the durable function. Thanks |
Sorry, for late reply. Was out on vacation. Here's my
Azure Functions Core Tools:
|
I'm unable to reproduce this exception using any of the environments described above, so the root cause must be something more subtle. I think the best we can do in azure-identity is to enable a workaround. I've done that in azure-identity 1.7.0b3, which is now available on PyPI. With 1.7.0b3, you can avoid importing pywin32 by not using a persistent cache. I doubt you'll miss anything by doing this--persistent caching doesn't make sense for a Functions app and during local development you're probably better served by authenticating through the Azure CLI or VS Code. SharedTokenCacheCredential still won't work, because it requires a persistent cache, but all the other credentials should be useable in 1.7.0b3. If you're using DefaultAzureCredential, you'll need to add an optional argument, unless you're configuring authentication through environment variables: |
To add to this issue, I am facing the same issue from VSCode when I am loading the azure-identity module: All these when I am using the debugger form vs code. Once I go to PowerShell 7 terminal and activate the same .venv there is no problem at all to start it (func host start) The issue should be related to the Azure function plugin or something on VS Code, as I changed the vs code settings to use as default terminal the PS 7 one (C:\Program Files\PowerShell\7\pwsh.exe) instead of the cmd.exe. Again though, in vs code execution I am getting the same error, and if I run an instance of the terminal alone all good. |
@chlowell using 1.7.0b3 solved the issue. Thanks! |
Just as a note, importing both of those using the commands above, in a VSCode Powershell terminal activated in my venv, worked fine with no errors, NOT using 1.7.0b3. However, if i then go and run my function in debug mode (F5), I still get the error |
Thank you everyone for contributing so much detail here. I've released a new stable version, 1.6.1, with the fix from 1.7.0b3. To summarize the situation:
I'm marking this issue resolved because I believe there's nothing more we can do in the Azure SDK to address it. Please feel free to unresolve this issue if you want to continue the discussion. |
Hi @Valdeminas. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “ |
Hi @Valdeminas, since you haven’t asked that we “ |
I'm trying to use azure keyvault in my python azure function.
When importing
azure.keyvault.secrets
, everything works fine.However, when I add
from azure.identity import DefaultAzureCredential
, build fails with (slightly redacted for privacy):This stack overflow question seems to deal with the same issue, but sadly does not have an answer :(
The text was updated successfully, but these errors were encountered: