如何在 Visual Studio 中的不同端口上运行 Azure Function 应用程序 [英] How to run Azure Function app on a different port in Visual Studio

查看:19
本文介绍了如何在 Visual Studio 中的不同端口上运行 Azure Function 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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)

解决方案

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

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%..LocalAzure.Functions.V2.Cli2.0.1-beta.22Azure.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

这篇关于如何在 Visual Studio 中的不同端口上运行 Azure Function 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆