http://localhost:7071/api/OrchestrationManager
public static class OrchestrationManagerFunctions { [FunctionName(nameof(OrchestrationManager))] public static async Task<IActionResult> OrchestrationManager( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, [DurableClient] IDurableOrchestrationClient starter, ILogger log) { /*--- Inits ---*/ log.LogInformation("C# HTTP trigger function processed a request."); var result = new List<string>(); var token = new CancellationToken(); /*--- Get/Display Orchestrations Currently Running ---*/ var instances = await starter.ListInstancesAsync(new OrchestrationStatusQueryCondition { }, token); Debug.Print("========================================================="); Debug.Print(" Orchestrations Currently Running"); Debug.Print("---------------------------------------------------------"); foreach (var item in instances.DurableOrchestrationState) { if (item.RuntimeStatus != OrchestrationRuntimeStatus.Running) { continue; } var mgr = starter.CreateHttpManagementPayload(item.InstanceId); var url = mgr.TerminatePostUri; var msg = $"Instance('{item.InstanceId}') - {item.Name} - Since {item.CreatedTime}"; result.Add(msg); Debug.Print(msg); } Debug.Print("========================================================="); /*--- Terminate All Running Instances ---*/ var foo = req.Query["term"]; if (Debugger.IsAttached && foo == "1") { foreach (var item in instances.DurableOrchestrationState) { if (item.RuntimeStatus != OrchestrationRuntimeStatus.Running) { continue; } var mgr = starter.CreateHttpManagementPayload(item.InstanceId); var uri = new Uri(mgr.TerminatePostUri); var httpRequest = (HttpWebRequest)WebRequest.Create(uri); httpRequest.Method = "POST"; var httpResponse = (HttpWebResponse)(await httpRequest.GetResponseAsync()); var httpResult = await new StreamReader(httpResponse.GetResponseStream()).ReadToEndAsync(); Debug.Print($"Instance('{item.InstanceId}') - {item.Name} - TERMINATED"); } Debug.Print("========================================================="); } return new OkObjectResult(result); } }