在本地Azure函数项目(.NET标准2.0)中找不到作业函数 [英] No job functions found in Azure Functions project (.NET standard 2.0) local
问题描述
我试图在.NET标准2.0中创建一个Azure Functions项目,因为我需要在该项目中使用.NET标准2.0类库。
I'm trying to create a Azure Functions project in .NET standard 2.0 because I need to use a .NET standard 2.0 class library in this project.
但是,当我尝试创建一个简单的Azure Functions项目并在本地运行时,出现以下错误:
However when I try to create a simple Azure Functions project and run it locally, I get the following error:
正如我之前说的那样,我的代码非常基础,但我还是会分享它。
As I said before my code is very basic but I'll share it anyway.
我的.csproj文件:
My .csproj file:
https://i.imgur.com/z5JiLn4.png
我的队列触发器:
https://i.imgur.com/HPzU4P4.png
我的Program.cs:
My Program.cs:
https://i.imgur.com/9hMujDV .png
(对不起,我无法发布图片)
(I'm sorry for the links, I can't post images yet)
推荐答案
-
您无需按顺序将Function App项目定位到.NET Standard使用.NET标准库。您可以从针对完整框架(
net461
)的项目中做到这一点。
You don't have to target Function App project to .NET Standard in order to use .NET Standard libraries. You can do that from a project targeting Full Framework (
net461
).
如果要定位.NET Standard,您需要2.0 / Core版本(仍处于预览状态)的Azure Functions工具才能运行它们。您可以通过运行 npm install -g azure-functions-core-tools @ core
来安装它们,然后运行 func start
从您的发布
文件夹中。请注意,此 func
将位于%APPDATA%\Roaming\npm
中,而不是如您的示例所示,为%APPDATA%\Local\Azure.Functions.Cli\1.0.7
。
If you want to target .NET Standard, you need 2.0/Core version (still in preview) of Azure Functions tools to be able to run them. You can install these by running npm install -g azure-functions-core-tools@core
and then running func start
from your publish
folder. Note that this func
will be in %APPDATA%\Roaming\npm
, not %APPDATA%\Local\Azure.Functions.Cli\1.0.7
as in your example.
如果要从Visual Studio运行.NET Standard项目,需要15.5版本预览,请参见对Visual Studio中Azure函数的改进。
If you want to run .NET Standard project from Visual Studio, you need 15.5 version preview, see Improvements to Azure Functions in Visual Studio.
请删除 Program.cs
:函数项目不需要。
Please remove Program.cs
: it's not needed for Functions project.
这篇关于在本地Azure函数项目(.NET标准2.0)中找不到作业函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!