Azure Logic Apps Standard: worflow’s run retention history configuration.

When you create an Azure Logic Apps Standard workflow for your integrations (maybe with your Dynamics 365 Business Central ERP, but this is obviously valid for every workflow you have) you have essentially two possibility:

  • Create a stateful workflow
  • Create a stateless workflow

A stateful workflow automatically saves all the operations’ inputs, outputs and states to external storage. This information makes reviewing the workflow run details and history possible after each run finishes and provides high resiliency. This type of workflow runs asynchronously by default.

A stateless workflow runs instead fully in memory, so state between actions and run history is not preserved. It runs only synchronously and it has a timeout of 5 minutes.

A stateful workflow (probably the most common workflow type in Azure Logic Apps) has a 90 days retention period by default for the history. But what if you have a different business requirement for this history retention?

I had recently a customer using Azure Logic Apps Standard for their business processes that, for auditing purposes, need to have a workflow history retention period greater than 90 days. How to change that?

How to change retention history in Azure Logic Apps Standard.

To change the retention history period to a different value, you need to perform some (not so easy) manual steps.

First of all, select your Azure Logic Apps Standard, then go to Settings and click on Environment Variable. In the App settings pane, create a new environment variable called Workflows.RuntimeConfiguration.RetentionInDays with the value (in days) you want to have for your Azure Logic App history retention:

Here I set this value to 30 days, so all runs that are older than 30 days will be deleted.

Please note that this setting is for the entire Azure Logic App Standard instance. In Azure Logic Apps Standard you can have N workflows inside the same Logic App instance. If you want to change the history retention only for a particular workflow, you can use the following per-workflow setting:

Workflows.<workflowName>.RuntimeConfiguration.RetentionInDays

If you change this setting to a value less than 90 days (default value) you also need to change another setting called Runtime.Backend.FlowRunTimeout. This sets the amount of time a workflow can continue running before forcing a timeout. The minimum value for this setting is 7 days and default is 90 days.

If you change the history retention to a lower value (in my sample above I’ve used 30 days) the Runtime.Backend.FlowRunTimeout setting must be changed to a value less than or equal to the value for the Workflows.RuntimeConfiguration.RetentionInDays setting, otherwise, run histories can get deleted before the associated jobs are completed.

The Runtime.Backend.FlowRunTimeout setting must be changed in the host.json file of your Azure Logic Apps instance (as every other runtime’s related settings). To do that:

  • Under Development Tools, select Advanced Tools.
  • On the Advanced Tools pane, select Go, which opens the Kudu environment for your Azure Logic App.
  • On the Kudu toolbar, open the Debug console menu, and select CMD.A console window opens so that you can browse to the wwwroot folder using the command prompt or directly by browsing the directory structure that appears above the console window.
  • Browse along the homesitewwwroot folder:

Edit the host.json file and insert the following lines:

"extensions": {
     "workflow": {
        "settings": {
           "Runtime.FlowMaintenanceJob.RetentionCooldownInterval": "01.00:00:00",
           "Runtime.Backend.FlowRunTimeout": "20.00:00:00"
        }
     }
   }

Here I’ve specified the following:

  • “Runtime.Backend.FlowRunTimeout”: “20.00:00:00”: workflow’s timeout set to 20 days (the value is just an example).
  • “Runtime.FlowMaintenanceJob.RetentionCooldownInterval”: “01.00:00:00”: This parameter sets the amount of time in days as the interval between when to check for and delete run history that you no longer want to keep. Default is to perform a check every 7 days, here I’ve set it to do a check every day.

After editing, save the host.json file to preserve the new changes.

Please note that the retention job will only work if the Logic App is started and the job will only process the retention for workflows that are in the enabled status.

I hope this post will help on managing these workflow’s settings, that honestly are quite tricky to handle at the moment…

Original Post https://demiliani.com/2024/10/28/azure-logic-apps-standard-worflows-run-retention-history-configuration/

0 Votes: 0 Upvotes, 0 Downvotes (0 Points)

Leave a reply

Follow
Sign In/Sign Up Sidebar Search
Popular Now
Loading

Signing-in 3 seconds...

Signing-up 3 seconds...