I am setting local host port in local.setting.json. Referring Microsoft doc https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local
The file looks like below
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"AzureWebJobsDashboard": ""
},
"Host": {
"LocalHttpPort": 7073
}
}
When I run/debug the solution , VS still host the app on default port (7071)
I have checked the bin directory, the local.setting.json
file is geting there with above settings.
Running Azure Fucntion CLI (func host start
) from bin directory correctly read the port number.
Looks like VS is not using the "LocalHttpPort
" port. Is there any other changes required in the settings. I have Visual Studio 2017 Preview (2)
I used the accepted answer but I still got an error when the debugger port was trying to bind because both function apps were trying to bind to 5858.
To get around that I added one more attribute to the application arguments in the project settings and my arguments look like this:
the command line takes precedence over the settings file, the problem is that VS passes an explicit port on the command line.
work around is to go through
project -> properties -> Debug
, then underApplication arguments
take control of the args. you can typehost start --pause-on-error
Edit from ravinsp:
Update for .Net Core 2.0 function project:
The command line arguments you have to pass are different. You have to pass in the path to a dll in front. Like this:
%AppData%\..\Local\Azure.Functions.V2.Cli\2.0.1-beta.22\Azure.Functions.Cli.dll host start --pause-on-error
You can see for yourself by running the function in Visual Studio and using the process explorer to see command line args to dotnet.exe process.edit: a word
I am using the CLI version 1.2.1, and the following
Application arguments
setting inProject Properties -> Debug
worked for me.host start --port 7074 --nodeDebugPort 5860
I followed @ahmelsayed's answer and in particular, @ravinsp's comments for .net core 2.0 comments. While very helpful and putting me on the right track, they did not work for me without a crucial and non-intuitive modification so I'm adding a fresh answer.
TL;DR;
If you've used NPM to install Azure Functions Core Tools 2.x Runtime then you may need to set Project/Properties/Debug/Application Arguments to:
Long answer follows ...
My Setup
During this exercise, my setup is fully up to date (at time of writing) and as follows:
Azure Functions Core Tools (installed as per the Develop and run Azure functions locally document from Microsoft) reports (in Git Bash):
me@MYDESKTOP ~ $ func <snip/> Azure Functions Core Tools (2.0.1-beta.24) Function Runtime Version: 2.0.11587.0
fwiw, the Functions App settings tab for this Functions App on Azure reads:
My Issue
When I run my functions project (with no application arguments) I get this in the console output:
This in and of itself might not be a problem, but I'm getting annoying "works on my machine, fails when publishing to azure" type issues, so I want to make sure that local execution is using same functions runtime as azure (i.e. 2.0.11587.0 which, as per the setup notes above, it is/should be, right?)
So, based on @ravinsp's instructions, I run a find on my C drive to locate Azure.Functions.Cli.dll - there's only one, and it's located at
C:\Users\<myuserid>\AppData\Local\Azure.Functions.V2.Cli\2.0.1-beta\Azure.Functions.Cli.dll
which seems very consistent with @ravinsp's answer.So, I add the following Project/Properties/Debug/Application Arguments:
then I DO get port 8888, but runtime weirdly is still being reported as 2.0.11353.
Solution
Given that running func from Git Bash as per the above showed runtime of 2.0.11587.0, I tried
which func
which returned/c/Users/<myuserid>/AppData/Roaming/npm/func
. I did a cat on it and long story short I could see that ultimately it was runningC:\Users\<myuserid>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\func.exe
, and that in that same directory there was afunc.dll
.So, I tried the following Project/Properties/Debug/Application Arguments:
then finally I do get ...
and, crucially, the error I was getting when publishing to Azure starts manifesting itself locally too.
Ok, now the runtimes all in sync, time to get down to fixing my actual bug :)