Skip to content

Instantly share code, notes, and snippets.

Avatar

Jess Panni jesspanni

  • endjin
View GitHub Profile
View StartFunction.cs
[FunctionName("AsyncHttpFunction")]
public static async Task<IActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req,
[OrchestrationClient​] IDurableOrchestrationClient starter,
ILogger log)
{
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
string instanceId = await starter.StartNewAsync("Orchestration", (int)(data.secondsToWait ?? 60)).ConfigureAwait(false);
View Orchestration.cs
[FunctionName("Orchestration")]
public async Task Run(
[OrchestrationTrigger]IDurableOrchestrationContext context,
ILogger log)
{
int secondsToWait = context.GetInput<int>();
await context.CallActivityAsync(nameof(Function1.LongRunningOperation), secondsToWait);
}
View ProcessingFunction.cs
[FunctionName(nameof(Function1.LongRunningOperation))]
public Task LongRunningOperation([ActivityTrigger]int secondsToWait, ILogger log)
{
log.LogInformation($"Doing something really interesting for {secondsToWait} seconds");
return Task.Delay(TimeSpan.FromSeconds(secondsToWait));
}
View DurableFunctionStarterResponse.json
{
"id": "66ee5d08196874aeb99c9e62ddc7b190",
"statusQueryGetUri": "https://asynchttpfunction.azurewebsites.net/runtime/webhooks/durabletask/instances/66ee5d08196945aeb44c9e62ddc7b190?taskHub=Orchestration&connection=Storage&code=FSVfJyGODSeKHPO0cM8Po9e1jMT7MghVMGuJqTaGTN56E1RUHnlVJg==",
"sendEventPostUri": "https://asynchttpfunction.azurewebsites.net/runtime/webhooks/durabletask/instances/66ee5d08196945aeb44c9e62ddc7b190/raiseEvent/{eventName}?taskHub=Orchestration&connection=Storage&code=FSVfJyGODSeKHPO0cM8Po9e1jMT7MghVMGuJqTaGTN56E1RUHnlVJg==",
"terminatePostUri": "https://asynchttpfunction.azurewebsites.net/runtime/webhooks/durabletask/instances/66ee5d08196945aeb44c9e62ddc7b190/terminate?reason={text}&taskHub=Orchestration&connection=Storage&code=FSVfJyGODSeKHPO0cM8Po9e1jMT7MghVMGuJqTaGTN56E1RUHnlVJg==",
"rewindPostUri": "https://asynchttpfunction.azurewebsites.net/runtime/webhooks/durabletask/instances/66ee5d08196945aeb44c9e62ddc7b190/rewind?reason={text}&taskHub=Orchestration&connectio
View DurableFunctionGetStatusUrl.json
{
"name": "Orchestration",
"instanceId": "66ee5d08196945aeb44c9e62ddc7b190",
"runtimeStatus": "Running",
"input": 10,
"customStatus": null,
"output": null,
"createdTime": "2019-09-17T16:10:17Z",
"lastUpdatedTime": "2019-09-17T16:10:18Z"
}
View StartLongRunningActivity.json
{
"name": "Start Long Running Task",
"type": "AzureFunctionActivity",
"typeProperties": {
"functionName": "AsyncHttpFunction",
"method": "POST",
"body": {
"secondsToWait": 60
}
},
View WaitForCompletion.cs
{
"name": "Wait For Completion",
"type": "WebActivity",
"dependsOn": [
{
"activity": "Start Long Running Task",
"dependencyConditions": [
"Succeeded"
]
}