Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@TsuyoshiUshio
Created July 12, 2017 17:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TsuyoshiUshio/365e5ce453d02a3f707635feeb513c8d to your computer and use it in GitHub Desktop.
Save TsuyoshiUshio/365e5ce453d02a3f707635feeb513c8d to your computer and use it in GitHub Desktop.
Durable Function sample for Azure Portal
{
"bindings": [
{
"name": "helloContext",
"type": "activityTrigger",
"direction": "in"
}
],
"disabled": false
}
{
"bindings": [
{
"name": "context",
"type": "orchestrationTrigger",
"direction": "in"
}
],
"disabled": false
}
{
"bindings": [
{
"authLevel": "anonymous",
"name": "req",
"type": "httpTrigger",
"direction": "in",
"route": "orchestrators/{functionName}",
"methods": [
"post"
]
},
{
"name": "$return",
"type": "http",
"direction": "out"
},
{
"name": "starter",
"type": "orchestrationClient",
"direction": "in"
}
],
"disabled": false
}
#r "Microsoft.Azure.WebJobs.Extensions.DurableTask"
public static string Run(DurableActivityContext helloContext)
{
string name = helloContext.GetInput<string>();
return $"Hello {name}!";
}
#r "Microsoft.Azure.WebJobs.Extensions.DurableTask"
public static async Task<List<string>> Run(DurableOrchestrationContext context)
{
var outputs = new List<string>();
outputs.Add(await context.CallFunctionAsync<string>("E1_SayHello", "Tokyo"));
outputs.Add(await context.CallFunctionAsync<string>("E1_SayHello", "Seattle"));
outputs.Add(await context.CallFunctionAsync<string>("E1_SayHello", "London"));
// returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
return outputs;
}
#r "Microsoft.Azure.WebJobs.Extensions.DurableTask"
#r "Newtonsoft.Json"
using System.Net;
public static async Task<HttpResponseMessage> Run(
HttpRequestMessage req,
DurableOrchestrationClient starter,
string functionName,
TraceWriter log)
{
// Function input comes from the request content.
dynamic eventData = await req.Content.ReadAsAsync<object>();
string instanceId = await starter.StartNewAsync(functionName, eventData);
log.Info($"Started orchestration with ID = '{instanceId}'.");
return starter.CreateCheckStatusResponse(req, instanceId);
}
@TsuyoshiUshio
Copy link
Author

Durable Functions / Samples . I write a code for Azure Portal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment