1

The problem

I have created an application which utilizes FastAPI and Azure Function Apps by following the guide https://learn.microsoft.com/en-us/samples/azure-samples/fastapi-on-azure-functions/azure-functions-python-create-fastapi-app/

However, I am unable to get debugging to work. The function host does successfully start, but the debugger is unable to connect. I receive the pop-up error connect ECONNREFUSED 127.0.0.1:9091.

I am on a Windows 10 system using Python 3.9.13, functions core tools v4, packages azure-functions, nest_asyncio, fastapi, and uvicorn. I am using the latest versions of the VSCode extensions Azure Functions v1.10.3 and Python v2023.2.0.

What I have tried

I have attempted to enable reload and debugging for uvicorn following the FastAPI guide at https://fastapi.tiangolo.com/tutorial/debugging/ with no luck.

Attempting to configure the --language-worker of the func start or func host start command results in the same error if using ptvsd or a failure to locate Python if attempting to use -m uvicorn --reload --debug.

Code As found in the aforementioned guide:

tasks.json

{
  "type": "func",
  "command": "host start",
  "problemMatcher": "$func-python-watch",
  "isBackground": true,
  "dependsOn": "pip install (functions)"
},

launch.json

{
  "name": "Attach to Python Functions",
  "type": "python",
  "request": "attach",
  "port": 9091,
  "preLaunchTask": "func: host start"
}
patyx
  • 324
  • 1
  • 3
  • 17

1 Answers1

0

There could be various causes of the error **ECONNREFUSED 127.0.0.1:9091**.

you can refer to SO #71532944 given by the user @HariKrishna for the various resolutions to fix this error during debugging process in Azure Functions in VS Code.

I have reproduced the issue in my environment by taking code from github repository which is available in the same MSDOC you have given in the question, and I could get the below results as shown below:

enter image description here

Output: enter image description here

Pravallika KV
  • 2,415
  • 2
  • 2
  • 7