【发布时间】:2021-05-20 13:18:43
【问题描述】:
我有一个 Web 作业,它应该从 Azure 队列中读取,并对找到的有效负载执行一些操作。我遇到的问题是网络作业无法启动,这是错误
[02/17/2021 15:40:11 > e80592: INFO] [15:40:10 ERR] 错误索引方法“Functions.ProcessStudentPerfQueueMessages” [02/17/2021 15:40:11 > e80592:信息] Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException:错误索引方法“Functions.ProcessStudentPerfQueueMessages” [02/17/2021 15:40:11 > e80592: INFO] ---> System.InvalidOperationException: 无法将参数 'message' 绑定到类型 'StudentMessage'。 [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:第 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:第 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 方法,IFunctionIndexCollector 索引,CancellationToken 取消令牌)在 C:\projects\azure-webjobs- sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs:第 196 行 [02/17/2021 15:40:11 > e80592: INFO] 在 Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexMethodAsync(MethodInfo 方法,IFunctionIndexCollector 索引,CancellationToken cancelToken) 在 C:\projects\azure-webjobs- sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs:第 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 方法,IFunctionIndexCollector 索引,CancellationToken cancelToken) 在 C:\projects\azure-webjobs- sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs:第 157 行 [02/17/2021 15:40:11 > e80592: INFO] 在 C:\projects\azure-webjobs- 中的 Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.IndexTypeAsync(类型类型,IFunctionIndexCollector 索引,CancellationToken 取消令牌) sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs:第 85 行 [02/17/2021 15:40:13 > 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 更改为 string,则 webjob 在 Azure 中成功启动。这是一个网络核心网络作业。请帮忙。
【问题讨论】:
-
StudentMessage这个类是怎么定义的?先看看这个:docs.microsoft.com/en-us/azure/azure-functions/…