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

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

问题描述

我正在local.setting.json中设置本地主机端口.引用Microsoft文档 https://docs.microsoft.com/zh-CN/azure/azure-functions/functions-run-local

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

文件如下所示

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "AzureWebJobsDashboard": ""   
  },
  "Host": {
    "LocalHttpPort": 7073
  }
}

运行/调试解决方案时,VS仍将应用程序托管在默认端口(7071)

When I run/debug the solution , VS still host the app on default port (7071)

我已经检查了bin目录,使用上面的设置,local.setting.json文件已到达该目录. 从bin目录运行 Azure Fucntion CLI (func host start)可以正确读取端口号.

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.

好像VS没有使用"LocalHttpPort端口.设置中是否还需要其他任何更改.我有Visual Studio 2017 Preview(2)

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)

推荐答案

更新:如果您只是想更改端口,则无需通过在中指定的文件进行设置问题.检查 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

原始答案:

命令行优先于设置文件,问题是VS在命令行上传递了显式端口.

the command line takes precedence over the settings file, the problem is that VS passes an explicit port on the command line.

解决方法是通过project -> properties -> Debug,然后在Application arguments下控制args.您可以输入host start --pause-on-error

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

从ravinsp

.Net Core 2.0功能项目的更新:

Update for .Net Core 2.0 function project:

您必须传递的命令行参数是不同的.您必须将路径传递到前面的dll.像这样: %AppData%\..\Local\Azure.Functions.V2.Cli\2.0.1-beta.22\Azure.Functions.Cli.dll host start --pause-on-error您可以通过在Visual Studio中运行该函数并使用进程浏览器查看dotnet.exe进程的命令行args来自己查看.

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.

一个字

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

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