Created
February 16, 2021 15:50
-
-
Save xximjasonxx/30793e0c0c8a21838b0189228c58b3f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[FunctionName("Cleanup_DurableFunctionInstances")] | |
public async Task Cleanup_DurableFunctionInstances( | |
[QueueTrigger(Constants.QUEUE_DURABLE_FUNCTION_CLEANUP, Connection = Constants.TABLE_STORAGE_CONNECTION)] string instanceId, | |
[DurableClient] IDurableOrchestrationClient client, | |
ILogger logger) | |
{ | |
try | |
{ | |
var result = await client.PurgeInstanceHistoryAsync(instanceId); | |
if (result?.InstancesDeleted > 0) | |
{ | |
logger.LogInformation($"Successfully purged ${result.InstancesDeleted} workflow instances for Id {instanceId}"); | |
} | |
else | |
{ | |
logger.LogWarning($"Attempted to purge the non-existent Durable Function context instance of {result}"); | |
} | |
} | |
catch (Exception ex) | |
{ | |
logger.LogError(ex, $"Failed to clean up instance {instanceId}"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment