我有基本的durable function代码:
namespace dotNetDurableFunction
{
public static class Function1
{
[FunctionName("Function1")]
public static async Task<List<string>> RunOrchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext context)
{
var outputs = new List<string>();
string name = context.GetInput<string>();
// Replace "hello" with the name of your Durable Activity Function.
outputs.Add(await context.CallActivityAsync<string>("Function1_Hello", name));
return outputs;
}
[FunctionName("Function1_Hello")]
public static string SayHello([ActivityTrigger] string name, ILogger log)
{
log.LogInformation($"Saying hello to {name}.");
return $"Hello {name}!";
}
[FunctionName("Function1_HttpStart")]
public static async Task<HttpResponseMessage> HttpStart(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestMessage req,
[DurableClient] IDurableOrchestrationClient starter,
ILogger log)
{
//var name = await req.Content.ReadAsStringAsync();
var name = "Bart";
log.LogInformation(name);
// Function input comes from the request content.
string instanceId = await starter.StartNewAsync("Function1", name);
log.LogInformation($"Started orchestration with ID = '{instanceId}'.");
return starter.CreateCheckStatusResponse(req, instanceId);
}
}
}
我想要实现的是通过传递参数
name
调用HTTP触发器,例如:
http://localhost:7071/api/Function1_HttpStart?name=Josh
然后从HTTP触发器传递参数到编排程序,最终传递给由编排程序调用的活动。目前在这段代码中,输出是
Saying hello to .
,因此看起来它没有通过代码传递参数,或者请求URL中的参数没有被读取。是否有任何方法可以实现这一点?