Logic apps : Workflow run clearance

Cahir McCullagh 20 Reputation points
2025-01-31T14:11:49.5066667+00:00

Hi, I have a logic app, with workflows that sometimes have debug mode turned on in production to resolve issues.
These workflows contain sensitive information, so the runs history will need to be cleared on a periodic schedule. I followed this walk through of how to do this Retention in Logic Apps Standard - Including the retention of Storage Container Logs
From which I added these two do our host.json "Runtime.FlowMaintenanceJob.RetentionCooldownInterval":"01.00:00:00", "Workflows.RuntimeConfiguration.RetentionInDays":
I deployed this to our staging environment yesterday, my understanding is that every day, this job should clean any old runs that have ran in the last 7 days, including any runs before this setting was deployed.
However I have not seen any runs being cleared.

Is my understanding of these settings correct?
Is there any further actions that need taken in order for this cleanup job to happen?

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,344 questions
0 comments No comments
{count} votes

Accepted answer
  1. Khadeer Ali 3,190 Reputation points Microsoft Vendor
    2025-01-31T15:31:29.2933333+00:00

    @Cahir McCullagh ,
    Welcome to Microsoft Q&A Platform!

    Thanks for reaching out. You're on the right track with your host.json settings. The RetentionCooldownInterval controls how often the cleanup job can run (daily in your case), and RetentionInDays (which I assume you've set to 7) controls how long run history is kept. However, the retention policy applies prospectively after you deploy the updated host.json. This means runs that occurred before the deployment won't be immediately deleted.

    The cleanup job will only start considering runs for deletion after the deployment. So, you'll need to wait 7 days from your deployment date for any runs older than 7 days from the deployment time to be deleted. It's also worth noting that the cleanup job might not run exactly at the start of each day.

    If you still don't see any cleanup after a week, here are some troubleshooting steps:

    1. Check Logic App Logs: Look for any errors related to "FlowMaintenanceJob" or "Retention" in Azure Monitor.
    2. Test with a Shorter Retention: Temporarily set RetentionInDays to 1 in staging to quickly verify the job is working. Remember to change it back.
    3. Redeploy: A redeployment can sometimes resolve transient issues.
    4. Storage Account: While less likely, check your Logic App's storage account for any errors.

    Reference:

    https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-limits-and-config?tabs=standard#run-duration-and-history-retention-limits

    By default, the app setting named Workflows.RuntimeConfiguration.RetentionInDays is set to keep 90 days of data. The host setting named Runtime.FlowMaintenanceJob.RetentionCooldownInterval is set to check every 7 days for old data to delete. If you leave these default values, you might see data up to 97 days old. For example, suppose Azure Logic Apps checks on Day X and deletes data older than Day X - 90 days, and then waits for 7 days before running again. This behavior results in data that ages up to 97 days before the job runs again. However, if you set the interval to 1 day, but leave the retention days at the default value, the maximum delay to delete old data is 90+1 days.

    Hope this helps. Do let us know if you have any further queries.


    If this answers your query, do click Accept Answer and Yes for "Was this answer helpful." And if you have any further questions, let us know.


1 additional answer

Sort by: Most helpful
  1. Cahir McCullagh 20 Reputation points
    2025-01-31T15:51:08.9166667+00:00

    As the cleanup job will not clear up old runs, what is the best way to do this in a production environment?
    Previously we had just re deployed our logic apps, but would rather find another solution.
    The cleanup settings will provide a solution for the future, but we also need to clear up past history


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.