Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to test Azure Function in Python locally #851

Closed
disssid opened this issue Jul 2, 2020 · 28 comments
Closed

Unable to test Azure Function in Python locally #851

disssid opened this issue Jul 2, 2020 · 28 comments

Comments

@disssid
Copy link

disssid commented Jul 2, 2020

I have an Azure Function written in Python which was working fine with Visual Studio Code. I was able to run it locally, test and even deploy to Azure. I checked it on the portal and the function is running fine for quite some time now.But after updating the Azure Function core tools version to 3, I'm getting this message when I run it locally
Invalid Message: "noDebug" is not supported for attach
and gave me the options to "Open launch.json" or "Cancel".

I did check my launch.json file and I didn't make any changes, here is the content of the file

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to Python Functions",
            "type": "python",
            "request": "attach",
            "port": 9091,
            "preLaunchTask": "func: host start"
        }
    ]
}

EDIT: I downgraded Azure Function core tools to 2.0 and the issue still exists. Is it something related to VS Code?

I did try creating a fresh Azure Function project using VS Code and copied all the functions to the new project and it worked. But the old project still has the issue.

If someone wants to still take a shot at it, I'll be more than happy to provide any information

@anthonychu
Copy link
Member

One thing to try is to delete your VS Code folder and regenerate it by running the Azure Functions Initialize project for VS Code command (I don’t recall the exact name right now. If you have your code in git, make a commit before trying this and you should see the difference, if any.

@EricJizbaMSFT Do you have other suggestions to try?

@ejizba
Copy link

ejizba commented Jul 2, 2020

I believe that error is coming from the Python extension in VS Code. Can you check the version of that and upgrade to the latest if you're not already on it?

@disssid
Copy link
Author

disssid commented Jul 3, 2020

@anthonychu

Azure Functions Initialize project for VS Code command

func init

Is this what you're referring to?

I removed the .vscode directory, tried the above command, it didn't work, so used the Azure function extension in VS Code to initialize the project, that kind of worked, it created the .vscode directory and the necessary files.

Now when I try to debug, it runs provides me with the local URL's for the functions and fails with the following timeout issue,

Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.

Http Functions:

        HttpTrigger_date_filter: [GET,POST] http://localhost:7071/api/HttpTrigger_date_filter

        HttpTrigger_exceltocsv: [GET,POST] http://localhost:7071/api/HttpTrigger_exceltocsv

[7/3/2020 6:14:38 AM] Host lock lease acquired by instance ID '00000000000000000000000040E996DC'.
[7/3/2020 6:15:31 AM] Starting worker process failed
[7/3/2020 6:15:31 AM] The operation has timed out.
[7/3/2020 6:15:31 AM] Starting worker process:py  c:/Users/Techspan/.vscode/extensions/ms-python.python-2020.6.91350/pythonFiles/lib/python/debugpy --listen 127.0.0.1:9091 --wait-for-client "C:\Users\Techspan\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.7/WINDOWS/X64/worker.py" --host 127.0.0.1 --port 59560 --workerId 6c7f4057-a3f6-4162-bdc2-cf452fbe3dd2 --requestId 025009b7-798f-44ce-9892-bee5d902b005 --grpcMaxMessageLength 2147483647
[7/3/2020 6:15:31 AM] py process with Id=11124 started
[7/3/2020 6:16:31 AM] Starting worker process failed
[7/3/2020 6:16:31 AM] The operation has timed out.
[7/3/2020 6:16:31 AM] Starting worker process:py  c:/Users/Techspan/.vscode/extensions/ms-python.python-2020.6.91350/pythonFiles/lib/python/debugpy --listen 127.0.0.1:9091 --wait-for-client "C:\Users\Techspan\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.7/WINDOWS/X64/worker.py" --host 127.0.0.1 --port 59560 --workerId efa26bb9-9d55-40a6-be55-ad87b8a39645 --requestId 40516e73-6555-4e4f-98c0-7b902075ced7 --grpcMaxMessageLength 2147483647
[7/3/2020 6:16:31 AM] py process with Id=25216 started
[7/3/2020 6:17:31 AM] Starting worker process failed
[7/3/2020 6:17:31 AM] The operation has timed out.
[7/3/2020 6:17:31 AM] Exceeded language worker restart retry count for runtime:python. Shutting down Functions Host
[7/3/2020 6:17:31 AM] Stopping host...
[7/3/2020 6:17:31 AM] Stopping JobHost
[7/3/2020 6:17:31 AM] Job host stopped
[7/3/2020 6:17:31 AM] Host shutdown completed.
Application is shutting down...

@EricJizbaMSFT

I did check the version of the Python extension on VS Code and I am using v2020.6.91350, which seems to be the latest update

@anthonychu @EricJizbaMSFT Thank you for the response guys, like I said the functions work fine in a fresh project. Unless you guys feel that this is a serious issue, I can go ahead and close it.

@FunnyBlue
Copy link

still have no clue how to solve this issue!
@anthonychu can you tell me more what folder needs to be deleted? the whole folder or only the .vscode or any other file? Thanks!
@disssid mind if you can elaborate on how you solve this?

@disssid
Copy link
Author

disssid commented Aug 25, 2020

@FunnyBlue I just created a new Azure Function project in another directory, copied over the directories consisting just the Function related files from my previous project and ran the new project, It worked fine.

Let me know if you want me to elaborate in detail

@ninamwa
Copy link

ninamwa commented Nov 27, 2020

I have the same problem. Have created multiple Azure Function projects, and using only the standard template, but get the same error...

@apawast
Copy link

apawast commented Dec 1, 2020

@ninamwa could you please share more information about the error you are getting?

@ghost
Copy link

ghost commented Dec 5, 2020

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@Kashish053
Copy link

I am also getting the same error not sure. Attahing the screen shots as well
image
image

@disssid
Copy link
Author

disssid commented Dec 10, 2020

@ninamwa @Kashish053 Did you guys try this
"Create a new Azure Function project in another directory, copy over the directories consisting just the function related files from the previous project and run the new project"

@arnaudsm
Copy link

This may be an edge case, but I had the same issue because I swapped the F5 and Ctrl-F5 keys in my vscode preferences. Pressing Ctrl-F5 (Debugging) instead of F5 (Start without debugging) solved the issue.

@JonasBergholz
Copy link

JonasBergholz commented Dec 15, 2020

I have the same Issue, but just with "Starting without debugging". With debugging the Project runs just fine, but because of this I can't deploy it to the azure functions app. I suspect a error in the launch.json file myself, but I don't know what to put in instead of attach. I mean you probably put in "launch" in the request option, but I don't know what other options I need to put in, in order to get the projekt running in the same way.

@paolosalvatori
Copy link

I'm having the same issue when working on WSL2. I tried the tutorial at https://docs.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python and when I start debugging with F5, I get the following error.

image

@anthonychu
Copy link
Member

+ @stefanushinardi @vrdmr @Hazhzeng for assistance.

@Hazhzeng
Copy link
Contributor

Hi @JonasBergholz and @paolosalvatori, thanks for raising this issue.
Could you check if the function app can be successfully started by the function core tools.
Installation:

  • npm install -g azure-functions-core-tools@3
    Run with Core Tools:
  • cd <your function app directory>
  • func host start --verbose

We want to distinguish if this is a VSCode bug or a Core Tools bug.

@JonasBergholz
Copy link

JonasBergholz commented Jan 12, 2021 via email

@dave-read
Copy link

I have same issue. Starting via the command line with func host start --verbose works fine.

From VS Code I can Debug, but "Run Without Debugging":

  • pops up the dialog with message "Invalid message: "noDebug" is not supported for "attach" and options "Cancel" "Open launch.json".
  • console log has:
    [2021-01-17T01:53:11.085Z] Host lock lease acquired by instance ID '000000000000000000000000D2A466C2'.
    [2021-01-17T01:54:05.988Z] Starting worker process failed
    [2021-01-17T01:54:05.988Z] The operation has timed out.

I'm on MacOS with:
Azure Functions Core Tools
Core Tools Version: 3.0.3160 Commit hash: 00aa7f43cc5c5f15241b5e6e5363256f19ceb990
Function Runtime Version: 3.0.14916.0

@zhenyuan0502
Copy link

I got the same issue, but it's not timeout like above situation and it still run the function.
Any update for this annoying message?

@apawast apawast transferred this issue from Azure/azure-functions-core-tools May 20, 2021
@apawast
Copy link

apawast commented May 20, 2021

@Hazhzeng can you please take a look at this again?

@ankku
Copy link

ankku commented Nov 2, 2021

Is there any update here, same issue, functions runs fine but the error message keeps prompting. Using VS Code and Python v3.9

@andreso-connecterra
Copy link

Any update? Thanks

@HariKrishna598
Copy link

Is there any update about this error Visual Studio Code - Invalid message no debug is supported for attach. I'm also getting same error.. did many times re-installing and also tried Vs Code System setup as well as user setup but no change in that error.

@zhenyuan0502
Copy link

I confirm that Azure Tool Core V4 still got this error as well, quite annoying when I press Ctrl F5 as usual behavior

@HariKrishna598
Copy link

I observed the strange behavior which is, When I run the .Net Stack azure functions with any trigger, it works perfectly in VS Code with any version of azure function core tools whereas If I run the other stack like Python, Javascript azure functions, it shows the many errors at every time

@vrdmr
Copy link
Member

vrdmr commented Feb 17, 2022

Hi @zhenyuan0502, @HariKrishnaRajoli-MT - If you could share the repro-steps for the same?

Also, could you update the host.json and Start with debugging and share the logs below, it'll help

{
  "version": "2.0",
  "logging": {
    "logLevel": {"default": "Trace"}
  }, ...
}

I have not been able to repro it locally and would appreciate it if you have a live repro. Thanks.

/cc @gavin-aguiar @YunchuWang

@YunchuWang
Copy link
Contributor

No new feedback from author

@HariKrishna598
Copy link

HariKrishna598 commented Jul 16, 2022

@vrdmr @YunchuWang

VSCodePythonDebugError

@psychomintra
Copy link

Help I'm still having the Launch.Json error but these instructions are a bit confusing in the comments, It's my first time using visual studio code and I have assignments due!!!

Screenshot (109)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests