【发布时间】:2016-03-03 17:57:42
【问题描述】:
总之,我有一个 Azure Web 作业通过 WebJobs SDK 的 ProcessQueueMessage 机制链接到 CloudQueue,使用 CloudQueueMessage 参数类型。当通过QueueTrigger 触发时,这会给我一个FunctionInvocationException。
详情
项目使用AddMessageAsync方法成功添加到CloudQueue:
await queue.AddMessageAsync(new CloudQueueMessage(JsonConvert.SerializeObject(myObject)));
并作为我的对象的预期 JSON 表示形式出现在队列中(来自 Cloud Explorer 中的消息文本预览):
{"EmailAddress":"example@mail.com",
"Subject":"Test",
"TemplateId":"00-00-00-00-00",
"Model":{"PropertyName1":"Test1","PropertyName2":"Test2"}
}
但是,当ProcessQueueMessage方法被触发时:
public static async void ProcessQueueMessage(
[QueueTrigger(queueName)] CloudQueueMessage message, TextWriter log)
...我收到FunctionInvocationException:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.ProcessQueueMessage ---> System.InvalidOperationException: Exception binding parameter 'message' ---> System.ArgumentNullException: String reference not set to an instance of a String.
Parameter name: s
at System.Text.Encoding.GetBytes(String s)
at Microsoft.WindowsAzure.Storage.Queue.CloudQueueMessage.get_AsBytes() in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\Common\Queue\CloudQueueMessage.Common.cs:line 146
at Microsoft.Azure.WebJobs.Host.PropertyHelper.CallPropertyGetter[TDeclaringType,TValue](Func`2 getter, Object this)
at Microsoft.Azure.WebJobs.Host.PropertyHelper.GetValue(Object instance)
at Microsoft.Azure.WebJobs.Host.Bindings.BindingDataProvider.GetBindingData(Object value)
at Microsoft.Azure.WebJobs.Host.Queues.Triggers.UserTypeArgumentBindingProvider.UserTypeArgumentBinding.BindAsync(IStorageQueueMessage value, ValueBindingContext context)
at Microsoft.Azure.WebJobs.Host.Queues.Triggers.QueueTriggerBinding.<BindAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.WebJobs.Host.Triggers.TriggeredFunctionBinding`1.<BindCoreAsync>d__7.MoveNext()
--- End of inner exception stack trace ---
at Microsoft.Azure.WebJobs.Host.Executors.DelayedException.Throw()
at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<ExecuteWithWatchersAsync>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown
这似乎表明 message 参数未能将 JSON 读入 CloudQueueMessage 对象......但它似乎不是我可以控制的。
有人对为什么会发生这种情况有任何建议吗?
版本信息
Microsoft.Azure.Webjobs 1.1.1
WindowsAzure.Storage 6.2.2-预览版
DNX 4.5.1
背景
【问题讨论】:
标签: azure azure-webjobs azure-webjobssdk azure-storage-queues