-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
72 lines (63 loc) · 2.38 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
namespace OrchestrationInputBindingRepro;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.DurableTask.Client;
using Microsoft.DurableTask;
using Microsoft.Azure.Functions.Worker.Extensions.DurableTask;
public static class Program
{
public static void Main()
{
var host = new HostBuilder()
.ConfigureFunctionsWebApplication(
// breaks orchestration input binding
// if you comment out this line, the orchestration successfully completes
builder => new DurableTaskExtensionStartup().Configure(builder)
)
.ConfigureServices(services =>
{
services.AddHttpClient();
services.Configure<KestrelServerOptions>(options =>
{
options.AllowSynchronousIO = true;
});
})
.Build();
host.Run();
}
}
public static class MyFunction
{
[Function(nameof(MyFunction))]
public static async Task<List<string>> RunOrchestrator(
[OrchestrationTrigger] TaskOrchestrationContext context)
{
var outputs = new List<string>
{
// Replace name and input with values relevant for your Durable Functions Activity
await context.CallActivityAsync<string>(nameof(SayHello), "Tokyo"),
await context.CallActivityAsync<string>(nameof(SayHello), "Seattle"),
await context.CallActivityAsync<string>(nameof(SayHello), "London")
};
return outputs;
}
[Function(nameof(SayHello))]
public static string SayHello([ActivityTrigger] string name, FunctionContext executionContext)
{
return $"Hello {name}!";
}
[Function("MyFunction_HttpStart")]
public static async Task<HttpResponseData> HttpStart(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
[DurableClient] DurableTaskClient client,
FunctionContext executionContext)
{
// Function input comes from the request content.
string instanceId = await client.ScheduleNewOrchestrationInstanceAsync(
nameof(MyFunction));
return client.CreateCheckStatusResponse(req, instanceId);
}
}