总之,我有一个 Azure Web 作业CloudQueue
通过 WebJobs SDK 的ProcessQueueMessage
机制使用CloudQueueMessage
参数类型链接到一个。这给了我一个FunctionInvocationException
何时通过QueueTrigger
.
细节
该项目已成功添加到CloudQueue
使用AddMessageAsync
方法:
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
背景