을 발생하지 바인딩 나는 다음과 같은 C# 기능 코드가 있습니다푸른 기능 - ICollector가 function.json
[FunctionName("UpdateCohortsByTenantFunction")]
[return: Queue("my-queue", Connection = "MyStorage")]
//note - I have tried both method decoration and parameter decoration
public static async Task Run([TimerTrigger("* * * * * *")]TimerInfo myTimer, IAsyncCollector<AudienceMessage> output)
{
//some logic
foreach (var audience in audiences)
{
await output.AddAsync(new AudienceMessage
{
AudienceId = audience.Id,
TenantId = tenant.Id
});
}
}
다음 function.json 생산 :
{
"generatedBy": "Microsoft.NET.Sdk.Functions.Generator-1.0.6",
"configurationSource": "attributes",
"bindings": [
{
"type": "timerTrigger",
"schedule": "* * * * * *",
"useMonitor": true,
"runOnStartup": false,
"name": "myTimer"
}
],
"disabled": false,
"scriptFile": "../bin/MyApp.App.Tasks.Functions.dll",
"entryPoint": "MyApp.App.Tasks.Functions.UpdateCohortsByTenantFunction.Run"
}
는 문서 here받는 따르면 json 출력에는 "대기"방향을 갖는 대기열에 대한 바인딩이 있어야합니다. 즉 :
{
"type": "queue",
"direction": "out",
"name": "$return",
"queueName": "outqueue",
"connection": "MyStorageConnectionAppSetting",
}
나는 NPM 도구를 통해 큐 (설정이 here 설명) 실행하려고
, 나는 다음과 같은 오류 얻을 :Run: Microsoft.Azure.WebJobs.Host: Error indexing method 'UpdateCohortsByTenantFunction.Run'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'output' to type IAsyncCollector`1. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).
문서는 시작 코드를 통해 바인딩에 대한 참조를 포함하지합니다. 필자는 위 링크 된 Microsoft 설명서 및 예제 코드에서 설명한 특성을 통해이 작업을 수행하지만 그렇지 않은 경우 오류 메시지가 나타납니다.
public static async Task Run(
[TimerTrigger("* * * * * *")]TimerInfo myTimer,
[Queue("my-queue", Connection = "MyStg")] IAsyncCollector<AudienceMessage> output)
function.json
바인딩 없음 출력이 없다가 예상되는 :
트릭을 수행 한 것으로 보입니다. 빠른 답변 주셔서 감사합니다. – jinwood