在本地不同的端口上运行 Azure Functions V3 (.NET 5) [英] Run Azure Functions V3 (.NET 5) on a different port locally

查看:26
本文介绍了在本地不同的端口上运行 Azure Functions V3 (.NET 5)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以前版本的 Azure Functions 中,我曾经能够在 Properties -> 中使用这一行.调试 ->应用参数

With previous versions of Azure Functions, I used to be able to use this line in Properties -> Debug -> Application Arguments

host start --port 7073 --pause-on-error

但是,在运行 .NET 5 的 Azure Functions V3 中,它不起作用.

However, in Azure Functions V3, running .NET 5, it doesn't work.

当我尝试运行它时收到以下消息.

I get the following message when I try to run it.

无法执行,因为找不到指定的命令或文件.可能的原因包括:

Could not execute because the specified command or file was not found. Possible reasons for this include:

  • 你拼错了一个内置的dotnet 命令.
  • 您打算执行 .NET 程序,但是dotnet-host 不存在.
  • 您打算运行一个全局工具,但是在 dotnet 上找不到具有此名称的可执行文件路径.

我是否需要为 .NET 5 使用不同的命令?还是放在一个完全不同的地方?

Do I need to use a different command for .NET 5? Or put it in a completely different place?

推荐答案

我对任务管理器进行了一些挖掘,当您从 VS 启动 Function 应用程序时,我可以看到运行了两个 dotnet 进程:

I did a little bit of digging with Task Manager and I can see that two dotnet processes run when you start the Function app from VS:

  • dotnet path/to/func-sdk/func.dll 主机启动 --port 7071 --pause-on-error
  • dotnet path/to/your/app/bin/AppName.dll --host 127.0.0.1 --port 51289 --workerId some-guid --requestId some-guid2 --grpcMaxMessage

这个命令好像改成了在bin/Debug/net5.0文件夹下运行的dotnet func.dll host start ...,而不是之前的func host开始.

It seems the command has been changed to dotnet func.dll host start ... that is run in the bin/Debug/net5.0 folder, instead of the previous func host start.

我们至少可以通过将 Application 参数设置为:

We are able to change the port at least by setting the Application arguments to:

%LOCALAPPDATA%AzureFunctionsToolsReleases3.23.5cli_x64func.dll"主机启动 --port 7073 --pause-on-error

"%LOCALAPPDATA%AzureFunctionsToolsReleases3.23.5cli_x64func.dll" host start --port 7073 --pause-on-error

但现在我们正在对函数版本进行硬编码:

But now we are hard-coding the Functions version :

我不确定是否可以从变量中获取函数版本/路径.如果有人知道,请发表评论:)

I'm not sure if it's possible to get the Functions version/path from variables. If someone knows, do leave a comment :)

这篇关于在本地不同的端口上运行 Azure Functions V3 (.NET 5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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