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"
}