Recently I have been working with Azure Durable Functions, which are an extension of the Azure Function platform. Durable Functions provide a way to define a workflow that maintains a state between executions or during asynchronous runs of each part of the workflow.
I intend to write several posts on Azure Functions in the coming months, but for now, I want to write about cleaning up after durable function workflows, as it took me some time to work out how to do it myself.
Durable Function History
If you already understand how durable functions maintain their state and history, scroll down to the next section; otherwise, keep reading to learn how durable state works.
Every output of a durable activity (or the orchestrator itself) is stored as part of the orchestration history; one of the requirements of activity functions is that their return type can be serialised and deserialised, and stored in JSON format. This JSON data is then stored in Azure Storage (blobs, queues, and tables) to be retrieved when the function resumes (after waiting on an activity or external event).
What isn’t immediately apparent to developers is that this history is stored forever, an ever-growing pile of JSON in your storage accounts.