我试图绑定ServiceBusTrigger为Azure函数2.0属性调用:属性IDictionary作为输入参数,如下所示:
public static class Function1
{
[FunctionName("Function1")]
public static void Run([ServiceBusTrigger("topic-name", "subscription-name", Connection = "connection-string")]string mySbMsg, string messageId, string correlationId, IDictionary<string,object> properties, ILogger log)
{
log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
}
}
我收到了错误:
Microsoft.Azure.WebJobs.Host:错误索引方法'Function1.Run' . Microsoft.Azure.WebJobs.Host:无法将参数'properties'绑定到类型IDictionary`2 . 确保绑定支持参数Type . 如果您正在使用绑定扩展(例如ServiceBus,Timers等),请确保您已在启动代码中调用扩展的注册方法(例如config.UseServiceBus(),config.UseTimers()等) .
作为我正在使用的来源:https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus文档 .
MessageId和CorrelationId工作正常 . 如何获取: Properties IDictionary<< String,Object >> 特定于应用程序的消息属性?
1 回答
对于v2函数,元数据
Properties
已更改为UserProperties
,请参阅相关的code和doc .你可以使用
IDictionary<string,object> userProperties
.