Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
335 stars 103 forks source link

[BUG] Add context get Exception: TypeError: main() got an unexpected keyword argument 'context' #1344

Closed wangzelin007 closed 11 months ago

wangzelin007 commented 11 months ago

Investigative information

Please provide the following:

Repro steps

Provide the steps required to reproduce the problem:
  1. I followed the documentation and added the context in the main function
  2. Restart my local function app
  3. Request to my local function app

code change: image

Expected behavior

Provide a description of the expected behavior.

Request successful

Actual behavior

Provide a description of the actual behavior observed.

The request failed with the following error: image

[2023-11-06T11:07:09.295Z] Executed 'Functions.CopilotService' (Failed, Id=eee9949f-0391-4ede-9bf5-45c101c83e14, Duration=1343ms)
[2023-11-06T11:07:09.296Z] System.Private.CoreLib: Exception while executing function: Functions.CopilotService. System.Private.CoreLib: Result: Failure
Exception: TypeError: main() got an unexpected keyword argument 'context'
Stack:   File "C:\Users\zelinwang\AppData\Roaming\nvm\v18.16.1\node_modules\azure-functions-core-tools\bin\workers\python\3.10/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 479, in _handle__invocation_request
    call_result = await self._loop.run_in_executor(
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "C:\Users\zelinwang\AppData\Roaming\nvm\v18.16.1\node_modules\azure-functions-core-tools\bin\workers\python\3.10/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 752, in _run_sync_func
    return ExtensionManager.get_sync_invocation_wrapper(context,
  File "C:\Users\zelinwang\AppData\Roaming\nvm\v18.16.1\node_modules\azure-functions-core-tools\bin\workers\python\3.10/WINDOWS/X64\azure_functions_worker\extension.py", line 215, in _raw_invocation_wrapper
    result = function(**args)

Known workarounds

Provide a description of any known workarounds.

Contents of the requirements.txt file:

Provide the requirements.txt file to help us find out module related issues.

azure-functions azure-cosmos openai==0.27.4 azure-search-documents>=11.4.0b3 PyJWT cryptography rapidfuzz msal httpx tiktoken

Related information

Provide any related information