Deleting A Logic App Without Log Analytics Configured? Export Run Details For Preservation And Analysis with PowerShell

Sometimes, companies face the need to delete important Logic Apps but need to retain detailed information about their runs. Especially when Log Analytics isn’t configured, maintaining a record of past executions for auditing, analysis, storage, or compliance purposes is vital.

This script automates the process of fetching all the runs from a specified Logic App, extracting relevant details, and exporting them to .json files for further analysis or record-keeping purposes.

This PowerShell script offers several advantages in scenarios where users contemplate deleting a Logic App or encounter constraints due to the absence of Log Analytics configuration:

Mitigating Data Loss: Deleting a Logic App removes its associated history, potentially erasing valuable insights into past executions. By utilizing the PowerShell script, users can export run details to preserve crucial data before proceeding with deletion. In regulated environments or for auditing purposes, maintaining records of Logic App runs is essential. The script facilitates the preservation of run details, ensuring compliance with regulatory requirements and enabling comprehensive auditing.

Flexibility in Run Export: In scenarios where Log Analytics isn’t configured or accessible, the script offers an independent solution for exporting Logic App run details. Users aren’t bound by the constraints of Log Analytics and can seamlessly extract data for analysis or archival purposes. The script provides flexibility in defining the output directory and file format, empowering users to tailor the export process according to their specific requirements.

Automation and Efficiency: Rather than manually extracting run details one by one, the script automates the process, enabling batch processing of Logic App runs. This significantly reduces the time and effort required to export large volumes of data, enhancing operational efficiency. Users can schedule the execution of the PowerShell script to run at predefined intervals, ensuring regular and systematic export of Logic App run details.

This is an example of the result of using this PowerShell.

{
    "Run Details": {
        "properties": {
            "waitEndTime": "2024-03-01T07:10:28.9188779Z",
                       "startTime":  "2024-03-01T07:10:28.9188779Z",
                       "endTime":  "2024-03-01T07:14:01.1365889Z",
                       "status":  "Failed",
                       "code":  "ActionFailed",
                       "error":  {
                                     "code":  "ActionFailed",
                                     "message":  "An action failed. No dependent actions succeeded."
                                 },
                       "correlation":  {
                                           "clientTrackingId":  "08584923298565597836003987229CU207"
                                       },
                       "workflow":  {
                                        "id":  "/subscriptions/xxxxxxxxxxx/resourceGroups/XX-XXX-XX/providers/Microsoft.Logic/workflows/LA-XXXXXXXXX-POC/versions/xxxxxxxxxxxxxx",
                                        "name":  "xxxxxxxxxxxxxx",
                                        "type":  "Microsoft.Logic/workflows/versions"
                                    },
                       "trigger":  {
                                       "name":  "manual",
                                       "inputsLink":  {
                                                          "uri":  "https://prod-55.westeurope.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/runs/08584923298565597836003987229CU207/contents/TriggerInputs?api-version=2016-06-01\u0026se=2024-04-04T18%3A00%3A00.0000000Z\u0026sp=%2Fruns%2F08584923298565597836003987229CU207%2Fcontents%2FTriggerInputs%2Fread\u0026sv=1.0\u0026sig=0oO052pLkmJpj7DAepYpoYQPrTXnD17eABMoI_SuNpQ",
                                                          "contentVersion":  "SeXxiBX729iPh16dStbKtQ==",
                                                          "contentSize":  39,
                                                          "contentHash":  {
                                                                              "algorithm":  "md5",
                                                                              "value":  "SeXxiBX729iPh16dStbKtQ=="
                                                                          }
                                                      },
                                       "outputsLink":  {
                                                           "uri":  "https://prod-55.westeurope.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/runs/08584923298565597836003987229CU207/contents/TriggerOutputs?api-version=2016-06-01\u0026se=2024-04-04T18%3A00%3A00.0000000Z\u0026sp=%2Fruns%2F08584923298565597836003987229CU207%2Fcontents%2FTriggerOutputs%2Fread\u0026sv=1.0\u0026sig=xsKG2tc7jdxJJqo9A3W_MD0mIrGtpskbDcSseRqE-v0",
                                                           "contentVersion":  "a+Tspez2SVAZ9sIcPBAGSg==",
                                                           "contentSize":  1319,
                                                           "contentHash":  {
                                                                               "algorithm":  "md5",
                                                                               "value":  "a+Tspez2SVAZ9sIcPBAGSg=="
                                                                           }
                                                       },
                                       "startTime":  "2024-03-01T07:10:28.9171171Z",
                                       "endTime":  "2024-03-01T07:10:28.9171171Z",
                                       "originHistoryName":  "08584923298565597836003987229CU207",
                                       "correlation":  {
                                                           "clientTrackingId":  "08584923298565597836003987229CU207"
                                                       },
                                       "status":  "Succeeded"
                                   },
                       "outputs":  {

                                   },
                       "response":  {
                                        "startTime":  "2024-03-01T07:10:28.9171171Z",
                                        "endTime":  "2024-03-01T07:12:28.9171171Z",
                                        "correlation":  {

                                                        },
                                        "code":  "ClientClosedRequest",
                                        "status":  "TimedOut",
                                        "error":  {
                                                      "code":  "ClientClosedRequest",
                                                      "message":  "The connection has been closed by the client while the server is still processing its request. Request tracking id \u002708584923298565597836003987229CU207\u0027."
                                                  }
                                    }
                   },
    "id":  "/subscriptions/xxxxxxxxxxx/resourceGroups/XX-XXX-XX/providers/Microsoft.Logic/workflows/LA-XXXXXXXXX-POC/runs/08584923298565597836003987229CU207",
    "name":  "08584923298565597836003987229CU207",
    "type":  "Microsoft.Logic/workflows/runs"
}, 

"Actions":
{
    "value":  [
                  {
                      "properties":  {
                                         "inputsLink":  {
                                                            "uri":  "https://prod-55.westeurope.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/runs/08584923298565597836003987229CU207/actions/Condition/contents/ActionInputs?api-version=2016-10-01\u0026se=2024-04-04T18%3A00%3A00.0000000Z\u0026sp=%2Fruns%2F08584923298565597836003987229CU207%2Factions%2FCondition%2Fcontents%2FActionInputs%2Fread\u0026sv=1.0\u0026sig=lUJRBMXTZXK2X-J-niWqKjK1jhKKMOy0gZW7pDZb_Io",
                                                            "contentVersion":  "VcJgxcEyXSxFSBf+CO4IaA==",
                                                            "contentSize":  25,
                                                            "contentHash":  {
                                                                                "algorithm":  "md5",
                                                                                "value":  "VcJgxcEyXSxFSBf+CO4IaA=="
                                                                            }
                                                        },
                                         "canResubmit":  true,
                                         "startTime":  "2024-03-01T07:13:56.8438876Z",
                                         "endTime":  "2024-03-01T07:13:58.3232409Z",
                                         "correlation":  {
                                                             "actionTrackingId":  "50e86726-67da-4a2b-b64d-63ee0b06a7ca",
                                                             "clientTrackingId":  "08584923298565597836003987229CU207"
                                                         },
                                         "status":  "Failed",
                                         "code":  "ActionFailed",
                                         "error":  {
                                                       "code":  "ActionFailed",
                                                       "message":  "An action failed. No dependent actions succeeded."
                                                   }
                                     },
                      "id":  "/subscriptions/xxxxxxxxxxx/resourceGroups/XX-XXX-XX/providers/Microsoft.Logic/workflows/LA-XXXXXXXXX-POC/runs/08584923298565597836003987229CU207/actions/Condition",
                      "name":  "Condition",
                      "type":  "Microsoft.Logic/workflows/runs/actions"
                  },
                  {
                      "properties":  {
                                         "inputsLink":  {
                                                            "uri":  "https://prod-55.westeurope.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/runs/08584923298565597836003987229CU207/actions/Initialize_variable_Method/contents/ActionInputs?api-version=2016-10-01\u0026se=2024-04-04T18%3A00%3A00.0000000Z\u0026sp=%2Fruns%2F08584923298565597836003987229CU207%2Factions%2FInitialize_variable_Method%2Fcontents%2FActionInputs%2Fread\u0026sv=1.0\u0026sig=ki-pG3ElkmY3GGO7XDykUK1_SwP3flJGMicWVwjFEeo",
                                                            "contentVersion":  "8LQjqFxi1kn06CVWRblTBQ==",
                                                            "contentSize":  64,
                                                            "contentHash":  {
                                                                                "algorithm":  "md5",
                                                                                "value":  "8LQjqFxi1kn06CVWRblTBQ=="
                                                                            }
                                                        },
                                         "canResubmit":  true,
                                         "startTime":  "2024-03-01T07:13:54.0050718Z",
                                         "endTime":  "2024-03-01T07:13:54.3965547Z",
                                         "correlation":  {
                                                             "actionTrackingId":  "dd0a7493-9cea-457e-bbbf-22b9cda43607",
                                                             "clientTrackingId":  "08584923298565597836003987229CU207"
                                                         },
                                         "status":  "Succeeded",
                                         "code":  "NotSpecified"
                                     },
                      "id":  "/subscriptions/xxxxxxxxxxx/resourceGroups/XX-XXX-XX/providers/Microsoft.Logic/workflows/LA-XXXXXXXXX-POC/runs/08584923298565597836003987229CU207/actions/Initialize_variable_Method",
                      "name":  "Initialize_variable_Method",
                      "type":  "Microsoft.Logic/workflows/runs/actions"
                  },
                  {
                      "properties":  {
                                         "inputsLink":  {
                                                            "uri":  "https://prod-55.westeurope.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/runs/08584923298565597836003987229CU207/actions/Initialize_variable_Querie_RelativePath/contents/ActionInputs?api-version=2016-10-01\u0026se=2024-04-04T18%3A00%3A00.0000000Z\u0026sp=%2Fruns%2F08584923298565597836003987229CU207%2Factions%2FInitialize_variable_Querie_RelativePath%2Fcontents%2FActionInputs%2Fread\u0026sv=1.0\u0026sig=t7EIY1rFWIZ91Scqyr3_e2LltC5vARtXqjt_cyuzsr4",
                                                            "contentVersion":  "LuEj19cQMUxIjDnr48BRjg==",
                                                            "contentSize":  76,
                                                            "contentHash":  {
                                                                                "algorithm":  "md5",
                                                                                "value":  "LuEj19cQMUxIjDnr48BRjg=="
                                                                            }
                                                        },
                                         "canResubmit":  true,
                                         "startTime":  "2024-03-01T07:13:56.1452411Z",
                                         "endTime":  "2024-03-01T07:13:56.1611035Z",
                                         "correlation":  {
                                                             "actionTrackingId":  "07028bc6-925d-4c7c-8f26-6bf52b4459df",
                                                             "clientTrackingId":  "08584923298565597836003987229CU207"
                                                         },
                                         "status":  "Succeeded",
                                         "code":  "NotSpecified"
                                     },
                      "id":  "/subscriptions/xxxxxxxxxxx/resourceGroups/XX-XXX-XX/providers/Microsoft.Logic/workflows/LA-XXXXXXXXX-POC/runs/08584923298565597836003987229CU207/actions/Initialize_variable_Querie_RelativePath",
                      "name":  "Initialize_variable_Querie_RelativePath",
                      "type":  "Microsoft.Logic/workflows/runs/actions"
                  },
                  {
                      "properties":  {
                                         "inputsLink":  {
                                                            "uri":  "https://prod-55.westeurope.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/runs/08584923298565597836003987229CU207/actions/Initialize_variable_RelativePath/contents/ActionInputs?api-version=2016-10-01\u0026se=2024-04-04T18%3A00%3A00.0000000Z\u0026sp=%2Fruns%2F08584923298565597836003987229CU207%2Factions%2FInitialize_variable_RelativePath%2Fcontents%2FActionInputs%2Fread\u0026sv=1.0\u0026sig=FN5vPoxPPtXqwUTawZWCCoDD577FBcyISw4b7AsP8k4",
                                                            "contentVersion":  "W0eIKtVYxtDOxh5MrNmeCg==",
                                                            "contentSize":  70,
                                                            "contentHash":  {
                                                                                "algorithm":  "md5",
                                                                                "value":  "W0eIKtVYxtDOxh5MrNmeCg=="
                                                                            }
                                                        },
                                         "canResubmit":  true,
                                         "startTime":  "2024-03-01T07:13:55.433751Z",
                                         "endTime":  "2024-03-01T07:13:55.4482694Z",
                                         "correlation":  {
                                                             "actionTrackingId":  "994cc832-833a-445f-b784-1a9a1c85d9d3",
                                                             "clientTrackingId":  "08584923298565597836003987229CU207"
                                                         },
                                         "status":  "Succeeded",
                                         "code":  "NotSpecified"
                                     },
                      "id":  "/subscriptions/xxxxxxxxxxx/resourceGroups/XX-XXX-XX/providers/Microsoft.Logic/workflows/LA-XXXXXXXXX-POC/runs/08584923298565597836003987229CU207/actions/Initialize_variable_RelativePath",
                      "name":  "Initialize_variable_RelativePath",
                      "type":  "Microsoft.Logic/workflows/runs/actions"
                  },
                  {
                      "properties":  {
                                         "inputsLink":  {
                                                            "uri":  "https://prod-55.westeurope.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/runs/08584923298565597836003987229CU207/actions/Response/contents/ActionInputs?api-version=2016-10-01\u0026se=2024-04-04T18%3A00%3A00.0000000Z\u0026sp=%2Fruns%2F08584923298565597836003987229CU207%2Factions%2FResponse%2Fcontents%2FActionInputs%2Fread\u0026sv=1.0\u0026sig=xy7As_2c_drwERNraivg3QTjWkVMm0JiF-EVcF9L6F4",
                                                            "contentVersion":  "pfCJnfA/DmQvDHCg1asiDA==",
                                                            "contentSize":  80,
                                                            "contentHash":  {
                                                                                "algorithm":  "md5",
                                                                                "value":  "pfCJnfA/DmQvDHCg1asiDA=="
                                                                            }
                                                        },
                                         "canResubmit":  true,
                                         "startTime":  "2024-03-01T07:13:57.6536825Z",
                                         "endTime":  "2024-03-01T07:13:57.6548866Z",
                                         "correlation":  {
                                                             "actionTrackingId":  "a8b35cc0-bc78-4fc8-8350-3f14e1fe8bac",
                                                             "clientTrackingId":  "08584923298565597836003987229CU207"
                                                         },
                                         "status":  "Failed",
                                         "code":  "ActionResponseTimedOut",
                                         "error":  {
                                                       "code":  "ActionResponseTimedOut",
                                                       "message":  "The execution of template action \u0027Response\u0027 is failed: the client application timed out waiting for a response from service. This means that workflow took longer to respond than the alloted timeout value. The connection maintained between the client application and service will be closed and client application will get an HTTP status code 504 Gateway Timeout."
                                                   }
                                     },
                      "id":  "/subscriptions/xxxxxxxxxxx/resourceGroups/XX-XXX-XX/providers/Microsoft.Logic/workflows/LA-XXXXXXXXX-POC/runs/08584923298565597836003987229CU207/actions/Response",
                      "name":  "Response",
                      "type":  "Microsoft.Logic/workflows/runs/actions"
                  }
        ]
    }
}

Here, we highlighted the most important information, which can be key when you need to understand what happened during the execution of this Logic App.

Using this PowerShell script requires entering your Resource Group, Logic App Name, and the directory where you want to export the run records, which will be saved as .json files. You will be prompted to input your credentials since the PowerShell uses the command Connect-AzAccount.

Upon completion, your exported results will resemble the provided example. Examining the generated files allows easy identification of the Logic App and provides insight into whether the runs succeeded or failed.


If you only wish to export and retain failed runs, you can utilize a similar PowerShell script:

I hope this can help you in the future.

Hope you find this helpful! If you enjoyed the content or found it useful and wish to support our efforts to create more, you can contribute towards purchasing a Star Wars Lego for Sandro’s son!

Author: Luis Rigueira

Luis Rigueira is a Enterprise Integration Consultant at DevScope

Leave a Reply

Your email address will not be published. Required fields are marked *

turbo360

Back to Top