首页 > 解决方案 > 由于绑定错误,Azure Webjob 无法启动

问题描述

我有一个网络作业,它应该从 Azure 队列中读取,并对找到的有效负载做一些事情。我遇到的问题是网络作业无法启动,这是错误

[02/17/2021 15:40:11 > e80592:INFO] [15:40:10 ERR] 错误索引方法“Functions.ProcessStudentPerfQueueMessages”[02/17/2021 15:40:11 > e80592:INFO] Microsoft。 Azure.WebJobs.Host.Indexers.FunctionIndexingException:错误索引方法“Functions.ProcessStudentPerfQueueMessages”[2021 年 2 月 17 日 15:40:11 > e80592:信息] ---> System.InvalidOperationException:无法绑定参数“消息”输入“学生信息”。 [02/17/2021 15:40:11 > e80592: INFO] 在 Microsoft.Azure.WebJobs.Host.Bindings.Data.ClassDataBindingProvider`1.TryCreateAsync(BindingProviderContext context) 在 C:\projects\azure-webjobs-sdk- rqm4t\src\Microsoft.Azure.WebJobs.Host\Bindings\Data\ClassDataBindingProvider.cs:line 35 [02/17/2021 15:40:11 > e80592: INFO] 在 Microsoft.Azure.WebJobs.Host.Bindings.Data .DataBindingProvider.TryCreateAsync(BindingProviderContext context) 在 C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Bindings\Data\DataBindingProvider.cs:line 41 [02/17/2021 15: 40:11 > e80592: INFO] 在 Microsoft.Azure.WebJobs.Host.Bindings.CompositeBindingProvider.TryCreateAsync(BindingProviderContext context) 在 C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\ Bindings\BindingProviders\CompositeBindingProvider.cs:第 23 行 [02/17/2021 15:40:11 > e80592: INFO] 在 Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexMethodAsyncCore(MethodInfo method, IFunctionIndexCollector index, CancellationToken cancellationToken) 在 C:\projects\azure- webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs:line 196 [02/17/2021 15:40:11 > e80592: INFO] 在 Microsoft.Azure.WebJobs.Host.Indexers C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs 中的 .FunctionIndexer.IndexMethodAsync(MethodInfo 方法,IFunctionIndexCollector 索引,CancellationToken cancelToken):第 149 行 [02/17 /2021 15:40:11 > e80592: INFO] --- 内部异常堆栈跟踪结束 --- [02/17/2021 15:40:11 > e80592: INFO] 在 Microsoft.Azure.WebJobs.Host.Indexers .FunctionIndexer.IndexMethodAsync(MethodInfo 方法,C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs:line 157 [02/17/2021 15:40:11 中的 IFunctionIndexCollector 索引,CancellationToken cancelToken) e80592:C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs 中 Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexTypeAsync(类型类型,IFunctionIndexCollector 索引,CancellationToken 取消令牌)中的信息]。 Host\Indexers\FunctionIndexer.cs:line 85 [02/17/2021 15:40:13 > e80592: INFO] [15:40:13 FTL] Web 作业启动失败C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs:line 85 [02/17/2021 15:40:13] 中的 IFunctionIndexCollector 索引,CancellationToken cancelToken) e80592: INFO] [15:40:13 FTL] Web 作业启动失败C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs:line 85 [02/17/2021 15:40:13] 中的 IFunctionIndexCollector 索引,CancellationToken cancelToken) e80592: INFO] [15:40:13 FTL] Web 作业启动失败

这是代码

public class Functions
{
    private readonly IService _service;
    public Functions(IService service)
    {
         _service = service;
    }
    public async Task ProcessStudentPerfQueueMessages([QueueTrigger("studentperf")] StudentMessage message)
    {
         await new StudentPerfQueueProcessor(_pascoService).ProcessMessage(message));
     }

目前队列中没有任何消息。如果我更改StudentMessage为 a string,则 webjob 在 Azure 中成功启动。这是一个网络核心网络作业。请帮忙。

标签: c#azure.net-corewebjob

解决方案


这里是学生班

public class StudentMessage
{
   public int StudentId { get; set; }
   public int SubjectId { get; set; }
   public StudentForm Form { get; set; }
   public Dictionary<int, AnswerStatus> QuestionAnswerStatus { get; set; }
   public string Message { get; set; }
   public DateTime Date { get; set; }
}

Doris Lv 让我想到了StudentMessage课堂。Message我决定在 StudentMessage 和 bam 中注释掉该属性!它成功启动了。一定是 Newtonsoft.json 的东西。


推荐阅读