【发布时间】:2021-02-16 13:39:28
【问题描述】:
我正面临一个奇怪的问题。搜索了多个问题,但并没有真正解决这个问题。我有以下默认模板代码。
[FunctionName("OrchFunction_HttpStart")]
public async Task<HttpResponseMessage> HttpStart(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestMessage req,
[DurableClient] IDurableOrchestrationClient starter,
ILogger log)
{
// Function input comes from the request content.
string instanceId = await starter.StartNewAsync("OrchFunction", null);
log.LogInformation($"Started orchestration with ID = '{instanceId}'.");
return starter.CreateCheckStatusResponse(req, instanceId);
}
在 Orchstrator 函数中我有以下代码
[FunctionName("OrchFunction")]
public async Task<List<string>> RunOrchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext context)
{
var outputs = new List<string>();
var data = context.GetInput<JobPayload>();
var inst=context.InstanceId;
// returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
return outputs;
}
这里的问题是我在var data = context.GetInput<JobPayload>(); 中得到NULL。不知道为什么,因为它是 T 类型,我在 HttpRequestMessage 中传递。我知道它错了,但尝试使用 var data = context.GetInput<HttpResponseMessage>(); ,仍然为空。这里有什么问题?我得到了context.InstanceId 的价值。
【问题讨论】:
标签: c# asp.net-core asp.net-core-3.1 azure-function-app azure-durable-functions