Compare Page Revisions
« Older Revision - Back to Page History - Current Revision
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 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; Debug.Print($"Instance('{item.InstanceId}') - {item.Name} - Since {item.CreatedTime}"); } Debug.Print("========================================================="); /*--- Terminate All Running Instances ---*/ 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(string.Empty); } }
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.