public static async Task<IActionResult> PurgeCities( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "purgecities")] HttpRequest req, [DurableClient] IDurableClient client, ILogger log) { var queryCondition = new OrchestrationStatusQueryCondition() { InstanceIdPrefix = "Orch", }; PurgeHistoryResult result = await client.PurgeInstanceHistoryAsync(default,default,default);
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req, [DurableClient] IDurableClient client, ILogger log) { log.LogWarning("Purging all orchestration data from the database"); int totalDeleted = 0; bool finished = false; // Stop after 25 seconds to avoid a client-side timeout var sw = Stopwatch.StartNew(); while (sw.Elapsed < TimeSpan.FromSeconds(25)) { // Purge all completed instances, dating back to the year 2000 PurgeHistoryResult result = await client.PurgeInstanceHistoryAsync( createdTimeFrom : new DateTime(2000, 1, 1), createdTimeTo : null, runtimeStatus : null); totalDeleted += result.InstancesDeleted; // The SQL provider only deletes at most 1000 instances per call if (result.InstancesDeleted < 1000) { finished = true; break; } } log.LogWarning($"Purge of {totalDeleted} instance(s) completed after {sw.Elapsed}. Finished = {finished}."); return(new OkObjectResult(new { totalDeleted, finished, })); }