首先,我查看了其他具有相同错误消息的 SO 帖子,但似乎没有一个帖子能解决我的问题。我尝试了很多排列和选择。我的函数构建良好,但无法在 CLI 中运行,我收到以下神秘错误。 MSFT 文档似乎也没有给出答案。
未找到工作职能。尝试公开您的工作类别和方法。如果您使用绑定扩展(例如 ServiceBus、Timers 等),请确保您已在启动代码中调用扩展的注册方法(例如 config.UseServiceBus()、config.UseTimers() 等) .)。
我正在尝试运行计时器作业,然后将消息集合写入事件中心。我缺少什么?我已经为此奋斗了几个小时。
功能:
[FunctionName("CreateData")]
public static async Task Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer,
[EventHub("murraytest", Connection = "evingest")] IAsyncCollector<string> myeventhub,
TraceWriter log)
{
await myeventhub.AddAsync("data1");
await myeventhub.AddAsync("data2");
await myeventhub.AddAsync("data3");
log.Info($"COMPLETED: {DateTime.Now}");
}
本地.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"Eventhub": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "",
"evingest": "Endpoint=sb://example.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=LtcqBLT5VWjg0dGMdIvxCcEGs8902010Y6y14iGg="
}
}
Packages
函数.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"
}