Instantly share code, notes, and snippets.

Embed
What would you like to do?
Durable Functions: HttpTrigger function which is used to start an orchestration function.
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;
namespace DurableFunctionsDemo
{
public static class HttpStart
{
[FunctionName("HttpStart")]
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "orchestration/{functionName}")]HttpRequestMessage req,
[OrchestrationClient]DurableOrchestrationClient orchestrationClient,
string functionName,
TraceWriter log)
{
log.Info("HttpStart triggered.");
dynamic eventData = await req.Content.ReadAsAsync<object>();
string instanceId = await orchestrationClient.StartNewAsync(functionName, eventData);
log.Info($"Started orchestration with ID = '{instanceId}'.");
return orchestrationClient.CreateCheckStatusResponse(req, instanceId);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment