forked from Azure/azure-functions-durable-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpStart.fs
30 lines (24 loc) · 1.05 KB
/
HttpStart.fs
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
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
namespace VSSample
open System
open System.Net.Http
open System.Net.Http.Headers
open Microsoft.Azure.WebJobs
open Microsoft.Azure.WebJobs.Extensions.Http
open Microsoft.Extensions.Logging
open FSharp.Control.Tasks
module HttpStart =
[<FunctionName("HttpStart")>]
let Run([<HttpTrigger(AuthorizationLevel.Function, "post", Route = "orchestrators/{functionName}")>] req: HttpRequestMessage,
[<OrchestrationClient>] starter: DurableOrchestrationClient,
functionName: string,
log: ILogger) =
task {
let! eventData = req.Content.ReadAsAsync<Object>()
let! instanceId = starter.StartNewAsync(functionName, eventData)
log.LogInformation(sprintf "Started orchestration with ID = '{%s}'." instanceId)
let res = starter.CreateCheckStatusResponse(req, instanceId)
res.Headers.RetryAfter <- RetryConditionHeaderValue(TimeSpan.FromSeconds(10.0))
return res
}