Ram*_*ngh 45 azure azure-functions visual-studio-2017
我在local.setting.json中设置本地主机端口.参考Microsoft doc https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local
该文件如下所示
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"AzureWebJobsDashboard": ""
},
"Host": {
"LocalHttpPort": 7073
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行/调试解决方案时,VS仍然在默认端口上托管应用程序(7071)
我已经检查了bin目录,该local.setting.json
文件正在进行上述设置.从bin目录运行Azure Fucntion CLI(func host start
)正确读取端口号.
看起来VS没有使用"LocalHttpPort
"端口.设置中是否需要进行任何其他更改.我有Visual Studio 2017预览版(2)
ahm*_*yed 75
命令行优先于设置文件,问题是VS在命令行上传递了一个显式端口.
解决方法是通过project -> properties -> Debug
,然后Application arguments
控制args.你可以输入host start --pause-on-error
从ravinsp编辑:
.Net Core 2.0功能项目的更新:
您必须传递的命令行参数是不同的.你必须将路径传递到前面的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进程来自行查看.
编辑:一个字
小智 41
我使用的是CLI 1.2.1版,以下Application arguments
设置Project Properties -> Debug
对我有用.
host start --port 7074 --nodeDebugPort 5860
当您通过NPM安装Azure Functions Core Tools 2.x Runtime时,Visual Studio 2017中的.NET Core 2.0/.NET Standard 2.0 Azure Functions项目的正确答案
我跟着@ ahmelsayed的回答,特别是@ ravinsp对.net core 2.0评论的评论.虽然非常有帮助并且让我走上了正确的轨道,但如果没有一个关键且非直观的修改,它们就无法为我工作,所以我正在添加一个新的答案.
如果您已使用NPM安装Azure Functions Core Tools 2.x Runtime,那么您可能需要将Project/Properties/Debug/Application Arguments设置为:
C:\Users\<myuserid>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\func.dll host start --port 8888 --pause-on-error
Run Code Online (Sandbox Code Playgroud)
答案很长......
在本练习中,我的设置完全是最新的(在撰写本文时),如下所示:
Azure Functions核心工具(根据开发和运行Azure本地文档从Microsoft安装)报告(在Git Bash中):
me@MYDESKTOP ~
$ func
<snip/>
Azure Functions Core Tools (2.0.1-beta.24)
Function Runtime Version: 2.0.11587.0
fwiw,Azure上此功能应用程序的Functions App设置选项卡显示:
Runtime version: 2.0.11587.0 (beta)
Run Code Online (Sandbox Code Playgroud)
当我运行我的函数项目(没有应用程序参数)时,我在控制台输出中得到这个:
[17/03/2018 21:06:38] Starting Host (HostId=MYMACHINE, Version=2.0.11353.0, ProcessId=<snip/>
Listening on http://localhost:7071/
Run Code Online (Sandbox Code Playgroud)
这本身可能不是问题,但我正在讨厌"在我的机器上工作,在发布到azure时失败"类型问题,所以我想确保本地执行使用与azure相同的函数运行时(即2.0.11587.0,按照上面的设置说明,它应该是,对吧?)
因此,根据@ ravinsp的说明,我在我的C驱动器上运行一个find来找到Azure.Functions.Cli.dll - 只有一个,它的位置C:\Users\<myuserid>\AppData\Local\Azure.Functions.V2.Cli\2.0.1-beta\Azure.Functions.Cli.dll
似乎与@ ravinsp的答案非常一致.
所以,我添加以下Project/Properties/Debug/Application Arguments:
C:\Users\<myuserid>\AppData\Local\Azure.Functions.V2.Cli\2.0.1-beta\Azure.Functions.Cli.dll host start --port 8888 --pause-on-error
Run Code Online (Sandbox Code Playgroud)
然后我得到端口8888,但运行时奇怪仍然被报告为2.0.11353.
[17/03/2018 21:13:02] Starting Host (HostId=MYMACHINE, Version=2.0.11353.0, ProcessId=<snip/>
Listening on http://localhost:8888/
Run Code Online (Sandbox Code Playgroud)
鉴于根据上面的Git Bash运行func显示2.0.11587.0的运行时,我尝试which func
了返回/c/Users/<myuserid>/AppData/Roaming/npm/func
.我做了一只猫,长话短说我可以看到最终它正在运行C:\Users\<myuserid>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\func.exe
,并且在同一个目录中有一个func.dll
.
所以,我尝试了以下Project/Properties/Debug/Application Arguments:
C:\Users\<myuserid>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\func.dll host start --port 8888 --pause-on-error
Run Code Online (Sandbox Code Playgroud)
然后我终于得到......
[17/03/2018 21:16:29] Starting Host (HostId=MYMACHINE, Version=2.0.11587.0, ProcessId=<snip/>
Listening on http://localhost:8888/
Run Code Online (Sandbox Code Playgroud)
而且,至关重要的是,发布到Azure时我遇到的错误也开始在本地显示.
好的,现在运行时都是同步的,有时间来修复我的实际bug :)
去做这个
选择Function App Project in Visual Studio -> Hit Alt+Enter
并导航到调试设置并设置
host start --port 8085 --nodeDebugPort 6890
Run Code Online (Sandbox Code Playgroud)
使用 Visual Studio 2022 和 Function v4,您可以在文件中设置端口launchSettings.json
:
{
"profiles": {
"<functionapp project name>": {
"commandName": "Project",
"commandLineArgs": "--port 7137",
"launchBrowser": false
}
}
}
Run Code Online (Sandbox Code Playgroud)
此设置也可以通过 UI 更新
Properties > Debug > General > Open debug launch profiles UI
::
这是我在 Intellij 中运行时在 local.settings.json 文件中使用不同端口的方式。您也可以使用任何其他 IDE,local.settings.json 可以在任何地方使用。
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "java"
},
"Host": {
"LocalHttpPort": 7072
},
"ConnectionStrings": {}
}
Run Code Online (Sandbox Code Playgroud)
我使用了可接受的答案,但是当调试器端口尝试绑定时仍然出现错误,因为两个功能应用程序都试图绑定到5858。
为了解决这个问题,我在项目设置中的应用程序参数中添加了另一个属性,我的参数如下所示:
host start --pause-on-error --nodeDebugPort 5860
Run Code Online (Sandbox Code Playgroud)
从这个版本开始:
Azure Functions Core Tools (3.0.2912 Commit hash: bfcbbe48ed6fdacdf9b309261ecc8093df3b83f2)
Function Runtime Version: 3.0.14287.0
Run Code Online (Sandbox Code Playgroud)
你只需要start --port 7074
在 Application Arguments 框中输入
归档时间: |
|
查看次数: |
12535 次 |
最近记录: |