【问题标题】:Try to build Azure function app in linux following error returns "No job functions found. Try making your job classes and methods public"尝试在 linux 中构建 Azure 函数应用程序,以下错误返回“未找到作业函数。尝试公开您的作业类和方法”
【发布时间】:2019-10-14 17:29:33
【问题描述】:

当我尝试在 Linux(Ubuntu 18.04) 中构建 azure 函数时,会返回以下错误。 以下是我在此过程中遵循的步骤。从 git 克隆存储库后。

dotnet build
func start --build

然后输出返回,

[5/29/19 6:46:18 AM] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[5/29/19 6:46:18 AM] Host initialized (49ms)
[5/29/19 6:46:18 AM] Host started (55ms)
[5/29/19 6:46:18 AM] Job host started
Hosting environment: Production
Content root path: /media/ishara/Data/MAS/SAGE/SageShipmentFunctions/SageShipmentFunctionsApp
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[5/29/19 6:46:23 AM] Host lock lease acquired by instance ID '000000000000000000000000CAE400CD'.

下面是关于我的系统的信息,

.NET Core SDK (reflecting any global.json):
 Version:   2.2.300
 Commit:    73efd5bd87

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  18.04
 OS Platform: Linux
 RID:         ubuntu.18.04-x64
 Base Path:   /usr/share/dotnet/sdk/2.2.300/

Host (useful for support):
  Version: 2.2.5
  Commit:  0a3c9209c0

.NET Core SDKs installed:
  2.2.300 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

【问题讨论】:

  • 您尝试过错误信息中的提示吗?公开类和方法?
  • 你克隆了什么仓库?
  • 实际上,当它是使用 F5 从 vscode 执行而不是直接从终端执行相同的命令时,这非常有效……有什么想法吗?有没有具体的环境变量需要设置?

标签: c# linux azure .net-core azure-functions


【解决方案1】:

尝试解决此类错误的几个选项:

  • 您从哪里运行“func start --build”? 确保从包含已构建工件的文件夹中运行它,例如bin\Debug\net461

  • 如果您从另一个项目或版本转换。

在 VS csproj 文件中,确保存在 AzureFunctionsVersion

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
...etc
  • 如果不是,您应该升级到最新的 Microsoft.NET.Sdk.Functions,有时示例中的代码仓库版本较低。

试试这些,看看它是否有效,如果没有,请提供代码 repo 链接将继续前进。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-20
    • 2020-05-29
    • 2021-09-19
    • 2019-04-06
    • 1970-01-01
    • 2015-03-11
    • 1970-01-01
    • 2019-12-31
    相关资源
    最近更新 更多