5
votes

I am trying to develop an @AzureFunctions using Xamarin Forms. But it is not accepting connections from the cell phone.

How to configure host, port of Azure Functions on Visual Studio 2017 to enable connections from * other than localhost connections?

How to accept connections from local network on Azure Functions (v2) ?

How to configure Host : Port of Azure Functions on Visual Studio 2017 ?

I want that it accepts like ASP.Net Core (.UseUrls("http://+:7071")):

Now listening on: http://[::]:7071

but it is only listening on

http://localhost:7071

Azure Functions host

GitHub Issue: How to configure Azure Functions (v2) listening Host / Domain ? https://github.com/Azure/azure-functions-core-tools/issues/537

2
Are you trying to connect from a real device or from an emulator ? I guess you need to connect your device to the same network first and make sure that you can access the computer from the device then it should be easyThomas
I am using a Real device, on the same WiFi, but can not connect, Azure Functions is only listening on localhostTony
The screenshot shows function was trigger by a http request. Did the request came from the phone or from somewhere else?Shahid Syed
You can't listen on anything other than localhost. As per the docs, you can change the port from the command line or in the config but that's it. (A couple months ago, I wasted about three days trying to work around the same thing...)McGuireV10
There is an open feature request for this and somebody did come up with a reverse-proxy work-around...McGuireV10

2 Answers

2
votes

This was solved with the recent updates made on Azure Functions (v2).
Now the Azure Functions listens on IP 0.0.0.0

Hosting environment: Production
Content root path: C:\Users\tonyv\source\repos\SistemaMulti\WebAPI\bin\Debug\netstandard2.0
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.

So we can just pick the computer IP address, for example http://192.168.15.16:7071/api/Ping, and use it and Azure Functions will respond on the LAN, as expected.

See https://github.com/Azure/azure-functions-core-tools/issues/537#issuecomment-399239887

1
votes

You can configure the port by specifying the func host command in the debug arguments and using the -p switch, but the hostname is hardcoded to localhost, as can be seen in the source code here.

There is an open issue on GitHub requesting this feature: https://github.com/Azure/azure-functions-core-tools/issues/174, so if this is important for you and you haven't done so already, be sure to chime in. The project owner is already on that thread.

Also, since this is all open source, you do have the option of submitting a PR to add this functionality. I definitely encourage this because the team often has a difficult time prioritizing scenarios that don't have broad or strategic application (the 80% cases), so PRs can be really helpful for rounding out the remaining long-tail of 20% use-cases.