我创建了一个Azure 函数,只要将新消息添加到 Azure ServiceBus 队列就会触发该函数。使用此代码可以正常工作:
#r "Newtonsoft.Json"
#load "..\shared\person.csx"
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
public static void Run(string message, TraceWriter log)
{
var person = JsonConvert.DeserializeObject<Person>(message,
new JsonSerializerSettings() {ContractResolver = new CamelCasePropertyNamesContractResolver()});
log.Verbose($"From DeserializeObject: {person.FirstName} {person.LastName}");
}
我已经看到我也可以将消息绑定到这样的 POCO:
public static void Run(Person message, TraceWriter log)
{
log.Verbose($"From DeserializeObject: {message.FirstName} {message.LastName}");
}
现在我想将消息绑定到 aBrokeredMessage
因为我需要访问消息的属性。