Skip to content

Instantly share code, notes, and snippets.

@marcduiker
Created November 5, 2017 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcduiker/e0e7cb5c7eb81614ab5a4470de95d74a to your computer and use it in GitHub Desktop.
Save marcduiker/e0e7cb5c7eb81614ab5a4470de95d74a to your computer and use it in GitHub Desktop.
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