azure-functions - 使用 Azure 函数 CLI 2x 创建 EvenHubTrigger
问题描述
我尝试将 Azure 函数 EventHubTrigger 1x 迁移到 2x。但是,我的 Azure 函数 CLI 2x 无法绑定我的触发器,我的输出是No job functions found. Try making your job classes and methods public..
这是我的项目
我不知道我想念什么配置
谢谢你的帮助
解决方案
首先,您的代码中没有绑定。首先,您错过了Function
绑定以及没有Trigger
绑定。下面是 EventHubTriggered Azure Function 的一个简单示例
public static class Function2
{
[FunctionName("Function2")]
public static async Task Run([EventHubTrigger("samples-workitems", Connection = "ConnectionString")] EventData[] events, ILogger log)
{
var exceptions = new List<Exception>();
foreach (EventData eventData in events)
{
string messageBody = Encoding.UTF8.GetString(eventData.Body.Array, eventData.Body.Offset, eventData.Body.Count);
// Replace these two lines with your processing logic.
log.LogInformation($"C# Event Hub trigger function processed a message: {messageBody}");
}
}
}
推荐阅读
- oracle-apex - SSO 回调配置
- python - 在 if-else 块中使用 try-except
- android - 安卓。从服务启动 Activity
- perl - 将从文本文件读取的行存储到 Perl 脚本中的变量
- swift - 为什么 SwiftUI 会对 Published 中的 willSet 做出反应
- react-native - 检查反应本机应用程序中的 ui 元素
- elasticsearch - 弹性搜索按布尔字段排序
- xpath - 如何根据xpath中同一行中另一个td的文本选择一个td值
- reactjs - ReactJS - 使用 useState 挂钩维护数值
- c# - .Where(x=> x.listFoos.Count() > 1) 是否计算所有子元素?