找不到工作职能。 尝试公开您的工作类和方法

首先,我查看了其他SOpost,并显示相同的错误消息,似乎没有解决我的问题。 我尝试了许多排列和选项。 我的函数构建正常,但不会在CLI中运行,我得到以下神秘错误。 MSFT文档似乎也没有答案。

找不到工作职能。 尝试公开您的工作类和方法。 如果您正在使用绑定扩展(例如ServiceBus,Timers等),请确保您已在启动代码中调用扩展的注册方法(例如config.UseServiceBus(),config.UseTimers()等)。

我正在尝试运行计时器作业,然后将一组消息写入事件中心。 我错过了什么? 我已经打了好几个小时。

function:

[FunctionName("CreateData")] public static async Task Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, [EventHub("murraytest", Connection = "evingest")] IAsyncCollector myeventhub, TraceWriter log) { await myeventhub.AddAsync("data1"); await myeventhub.AddAsync("data2"); await myeventhub.AddAsync("data3"); log.Info($"COMPLETED: {DateTime.Now}"); } 

local.settings.json:

 { "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "Eventhub": "UseDevelopmentStorage=true", "AzureWebJobsDashboard": "", "evingest": "Endpoint=sb://example.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=LtcqBLT5VWjg0dGMdIvxCcEGs8902010Y6y14iGg=" } } 

的NuGet

function.json – 缺少任何eventhub绑定!

 { "generatedBy": "Microsoft.NET.Sdk.Functions-1.0.0.0", "configurationSource": "attributes", "bindings": [ { "type": "timerTrigger", "schedule": "0 */5 * * * *", "useMonitor": true, "runOnStartup": false, "name": "myTimer" } ], "disabled": false, "scriptFile": "..\\bin\\AzFuncs.dll", "entryPoint": "AzFuncs.Function1.Run" } 

您应该升级到最新的Microsoft.NET.Sdk.Functions (截至今天为1.0.6 )和Microsoft.Azure.WebJobs.Service.Bus (如果在完整框架上运行,则为2.1.0-beta4 )。 您可能需要先删除ServiceBus引用才能升级SDK。

还需要删除Microsoft.Azure.Eventhubs包。 所有相关类型等都在Microsoft.Azure.WebJobs.Service.Bus

还要记得在包管理器中检查“Include prerelease”以查找2.1.0-beta4