- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下 C# 函数代码:
[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 输出应包含与我的队列的绑定(bind),并具有“out”方向。即:
{
"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.).
该文档不包含对通过启动代码进行绑定(bind)的引用。我的理解是,这是通过上面链接的 Microsoft 文档和我的示例代码中描述的属性来完成的,但错误消息表明并非如此。
最佳答案
你应该用属性来装饰你的参数,而不是返回值:
public static async Task Run(
[TimerTrigger("* * * * * *")]TimerInfo myTimer,
[Queue("my-queue", Connection = "MyStg")] IAsyncCollector<AudienceMessage> output)
function.json
中预计不会有输出绑定(bind)。属性定义的绑定(bind)不会传输到生成的 function.json
。它们仍然可以工作,不用担心。
关于Azure Functions - ICollector 绑定(bind)不在结果 function.json 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47284972/
我已经为我的测试类重载了 Azure ICollector 接口(interface)。 但是,当创建收集器并添加数据时,初始化的两个收集器将被视为单个收集器。 下面是我的收集器类代码。 using
我已经为我的测试类重载了 Azure ICollector 接口(interface)。 但是,当创建收集器并添加数据时,初始化的两个收集器将被视为单个收集器。 下面是我的收集器类代码。 using
我有一个 Azure WebJob,它循环遍历文件页面并处理它们。该作业还有一个 ICollector 到输出队列: [Queue("batch-pages-to-process")] ICollec
我有以下 C# 函数代码: [FunctionName("UpdateCohortsByTenantFunction")] [return: Queue("my-queue", Connection
ICollector 和有什么区别和 IAsyncCollector在 Azure Functions 中编写 C# 函数(也适用于 WebJobs)? 我从示例中了解到,这些接口(interface
我是一名优秀的程序员,十分优秀!