Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Azure Function app on a different port in Visual Studio

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)

like image 475
Ramkumar Singh Avatar asked Jul 07 '17 17:07

Ramkumar Singh


People also ask

What port does Azure function use?

It is cool to run a single Azure Function. It will by default run on the local port 7071.

How do I deploy a function app in Azure from Visual Studio?

You can use a function app to group functions as a logical unit for easier management, deployment, scaling, and sharing of resources. From the Visual Studio menu, select File > New > Project. In Create a new project, enter functions in the search box, choose the Azure Functions template, and then select Next.

How do I change the Azure function in Visual Studio?

In the Azure portal, browse to your function app. Under Settings, choose Configuration. In the Function runtime settings tab, locate the Runtime version. Note the specific runtime version.


2 Answers

I am using the CLI version 1.2.1, and the following Application arguments setting in Project Properties -> Debug worked for me.

host start --port 7074 --nodeDebugPort 5860

like image 83
Thuc Nguyen Avatar answered Nov 21 '22 18:11

Thuc Nguyen


Update: If you're just looking to change the port, you don't have to set it through the file specified in the question. Check Thuc Nguyen answer

Original answer:

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 under Application arguments take control of the args. you can type host start --pause-on-error

enter image description here

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

like image 26
ahmelsayed Avatar answered Nov 21 '22 17:11

ahmelsayed