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"
}
2
  • I have a very similar problem. Mine is an http_trigger. I'm getting error connect econnrefused 127.0.0.1:7071, under Azure Workspace > local project > functions Commented Apr 16, 2024 at 0:26
  • In launch.json, I changed port setting from 7071 to 9091. For a brief moment, i saw local function-names listed in Azure Workspace > Local Project > Functions. But when i restarted vscode, again i got the connect error. Commented Apr 16, 2024 at 1:02

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

You say you "reproduced the issue", but you go successful output. Reproducing the issue means getting the wrong output. Don't you mean you could 'not' reproduce the issue?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.