代码如下:
[return: Table("AnalysisDataTable", Connection = "TableStorageConnection")]
public static async Task<OrchestrationManagerAnalysisData> InputQueueTriggerHandler(
[QueueTrigger("DtOrchestrnRequestQueueName",
Connection = "StorageQueueConnection")] string queueMsg,
[OrchestrationClient] DurableOrchestrationClient client, ILogger logger)
{
logger.LogInformation($"***DtOrchestrationRequestQueueTriggerHandler(): queueMsg = {queueMsg}");
await ProcessInputMessage(queueMsg, client, logger);
// Below is where the code goes to format the TableStorage Entity called analysisData.
// This return causes the above output binding to be executed, saving analysis data to
// Table Storage.
return analysisData;
}
上面的代码工作正常,并将analysisData保存到TableStorage。
但是,当我将输出绑定属性放在以编程方式调用的ProcessInputMessage()上时 而是作为触发器的结果调用,一切正常,除非没有数据输出 到表存储。
[return: Table("AnalysisDataTable", Connection = "TableStorageConnectionName")]
public static async Task<OrchestrationManagerAnalysisData>
ProcessInputMessage(string queueMsg, DurableOrchestrationClient client, ILogger logger)
{
// Do the processing of the input message.
// Below is where the code goes to format the TableStorage Entity called analysisData.
// This return causes the above output binding to be executed, saving analysis data to
// Table Storage.
return analysisData;
}
问题是否可以通过WebJob中的另一个函数以编程方式调用时,导致输出绑定到“触发器”?
我喜欢输出绑定的省力特性,并希望尽可能多地利用它们,同时还具有充分分解的代码,即每种方法中的内聚性很强。
谢谢, 乔治
答案 0 :(得分:0)
当从WebJob中的另一个函数以编程方式调用时,是否有一种方法可以使输出绑定到“触发器”?
简而言之,否。
您可以使用return value of the function发送数据,该article在函数中应用输出绑定属性。因此,如果要调用另一个函数并将数据写入表存储。
如果要实现所需的想法,则需要覆盖return
方法。但是,这是一种包集成方法,因此我建议您可以使用将客户实体插入表存储的TableOperation
对象。
TableOperation insertOperation = TableOperation.Insert(customer1);
// Execute the insert operation.
table.Execute(insertOperation);
有关更多详细信息,您可以参考此Map。