Azure / azure-functions-core-tools

Command line tools for Azure Functions
MIT License
1.3k stars 431 forks source link

Make it more obvious 7071 is the default port #2963

Open rhavenn opened 2 years ago

rhavenn commented 2 years ago

Debian 11 (Bullseye) installed via WSL2 (Win 11). I have a Python timer function I'm trying to test. func starts successfully and is listening on the port it shows. no errors. doing curl requests I get the below error and am not able to connect.

azurite and core tools installed via NPM. azurite --version : 3.15.0 func --version : 4.0.3971

azurite started with: azurite --silent --location ~/temp/azurite --debug ~/temp/azurite/debug.log no errors.

func started inside the python venv and it loads the function in question. ss -ltp shows the port listening. func start:

Found Python version 3.9.2 (python3).

Azure Functions Core Tools
Core Tools Version:       4.0.3971 Commit hash: d0775d487c93ebd49e9c1166d5c3c01f3c76eaaf  (64-bit)
Function Runtime Version: 4.0.1.16815

Functions:

        DataExportToPowerBI: timerTrigger

For detailed output, run func with --verbose flag.
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2 POST http://127.0.0.1:40257/AzureFunctionsRpcMessages.FunctionRpc/EventStream application/grpc -
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint 'gRPC - /AzureFunctionsRpcMessages.FunctionRpc/EventStream'
[2022-02-24T00:49:25.841Z] Worker process started and initialized.
[2022-02-24T00:49:30.392Z] Host lock lease acquired by instance ID '000000000000000000000000AEC7D6B0'.

I can telnet to the port and get a connection. So, I know the service is listening. running the curl command:

curl -H "Content-Type: application/json" -X POST -d '{"input":""}' http://127.0.0.1:40257/admin/functions/DataExportToPowerBI

fails with:

curl: (1) Received HTTP/0.9 when not allowed

All the docs I can find indicate nothing else is needed. Am I missing something? or is there a bug here?

https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=v4%2Cwindows%2Ccsharp%2Cportal%2Cbash#start

and various blogs is what I've been working off of. At the moment I'm more of the "hello world". the function does nothing more than print "hello" at this time, but runs if I call it via python3 .

ejizba commented 2 years ago

Hi, can you try port 7071 instead of 40257?

rhavenn commented 2 years ago

port 7071 connects and returns nothing, but depending on how that works that would seem to be correct. The --verbose logging output is showing a curl connection in the func "window". So, it's seeing it.

On a documentation note. I don't see a reference to 7071 anywhere in the output of func or docs, but I might have missed it.

https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=v4%2Cwindows%2Ccsharp%2Cportal%2Cbash#start

that has a 7071 listed in one of the examples, but it isn't explained and if I was reading that would think that was one of the random ports it was picking.

ejizba commented 2 years ago

Based on the description of your timer trigger (just a "hello world"), it makes sense it doesn't return anything. As long as you're seeing an execution in the logs, that means it's working (although I don't think you should need --verbose to see that).

Yeah port 7071 is the default. If you had any http trigger urls, you would see 7071 listed as the port for the urls in this section:

Functions:

    DataExportToPowerBI: timerTrigger

I can leave this issue open to either improve the docs or improve the logs from func start. The 40257 port is an internal detail and shouldn't be accessed directly. Perhaps we should hide that port in the logs by default

rhavenn commented 2 years ago

thank you for the explanation. I appreciate your assistance.