Skip to content

Instantly share code, notes, and snippets.

View jesspanni's full-sized avatar

Jess Panni jesspanni

  • MakerX
View GitHub Profile
[FunctionName("AsyncHttpFunction")]
public static async Task<IActionResult> RunAsync(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req,
[Orchestration​Client​] 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);
@jesspanni
jesspanni / Orchestration.cs
Created September 17, 2019 19:05
Orchstration.cs
[FunctionName("Orchestration")]
public async Task Run(
[OrchestrationTrigger]IDurableOrchestrationContext context,
ILogger log)
{
int secondsToWait = context.GetInput<int>();
await context.CallActivityAsync(nameof(Function1.LongRunningOperation), secondsToWait);
}
[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));
}
{
"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
{
"name": "Orchestration",
"instanceId": "66ee5d08196945aeb44c9e62ddc7b190",
"runtimeStatus": "Running",
"input": 10,
"customStatus": null,
"output": null,
"createdTime": "2019-09-17T16:10:17Z",
"lastUpdatedTime": "2019-09-17T16:10:18Z"
}
{
"name": "Start Long Running Task",
"type": "AzureFunctionActivity",
"typeProperties": {
"functionName": "AsyncHttpFunction",
"method": "POST",
"body": {
"secondsToWait": 60
}
},
{
"name": "Wait For Completion",
"type": "WebActivity",
"dependsOn": [
{
"activity": "Start Long Running Task",
"dependencyConditions": [
"Succeeded"
]
}