【发布时间】:2021-06-21 20:41:19
【问题描述】:
我有基本的持久功能代码:
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 触发器传递给 orchestrator,最后传递给 Orchestrator 调用的 Activity。
现在在这段代码中,输出是 Saying hello to .,所以看起来它没有通过代码传递参数,或者没有从请求 url 中读取参数。
有什么办法可以做到吗?
【问题讨论】:
-
我不完全理解代码,但我不明白你如何传递参数。也许这有帮助:c-sharpcorner.com/UploadFile/ca2535/query-string-in-Asp-Net
标签: c# .net azure azure-functions azure-durable-functions