Search code examples
python-3.xazurekeyerrorpython-wheelazure-function-app

KeyError when deploying Python Function App on Azure


I'm new to azure and I'm getting this KeyError when deploying my python function on Azure portal, not sure what is the reason.

I have added just one package, "tweepy == 3.8.0" in my requirements.txt and it seems like it is crashing mostly right during it's installation during deployment, And the PySocks package is probably just a dependency for tweepy package.

I have no such issues when the debug it locally. The function runs absolutely fine locally.

How can I resolve this deployment issue?

Error:

There was an error restoring dependencies. Traceback (most recent call last):
  File "C:\Users\anjan\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\anjan\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\anjan\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\tools\python\packapp\__main__.py", line
234, in <module>
    main()
  File "C:\Users\anjan\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\tools\python\packapp\__main__.py", line
60, in main
    find_and_build_deps(args)
  File "C:\Users\anjan\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\tools\python\packapp\__main__.py", line
142, in find_and_build_deps
    wheel.install(paths, maker)
  File "C:\Users\anjan\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\tools\python\packapp\distlib\wheel.py",
line 519, in install
    row = records[u_arcname]
KeyError: 'PySocks-1.7.0.dist-info/'

enter image description here


Solution

  • "func: pack" task has been a common problem for users. I could solve it by trying a preview feature that is meant to address this: https://github.com/microsoft/vscode-azurefunctions/wiki/Server-Side-Build