Search code examples
azurepostmanhttprequestazure-logic-apps

How to get data from Azure Workflow Trigger Histories - List


I have an Azure Logic App that has failed actions (the number is too big so I won't resubmit them manually).

I tried wtih the Azure documentation to list all of the operations:

https://learn.microsoft.com/en-us/rest/api/appservice/workflow-trigger-histories/list?view=rest-appservice-2023-12-01&tabs=HTTP

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/hostruntime/runtime/webhooks/workflow/api/management/workflows/{workflowName}/triggers/{triggerName}/histories?api-version=2023-12-01

However the response seems to be limited to 30 when I do the curl request. Even through the Azure Portal I don't get a full list, but only get 40 responses at a time: Example

Is there a way to list all of the failed actions with 1 request only?

Thanks!


Solution

  • Since you have 240K failed workflow runs and you don't want to use nextLinks hundreds of times, using the Workflow Trigger Histories - List API doesn't seem to be the best approach for you.

    I can suggest an alternative solution - using the Query - Get API of the Log Analytics service.

    First, you need to make sure your Logic Apps send Workflow Runtime Logs to Log Analytics workspace:

    enter image description here

    This will allow you to query the LogicAppWorkflowRuntime table using REST API.

    For example, to run the following Kusto query

    LogicAppWorkflowRuntime
    | project _ResourceId, WorkflowName, OperationName, StartTime, EndTime, Code, Status, Error, RunId, WorkflowId, OriginRunId, ClientTrackingId
    | where OperationName == "WorkflowRunCompleted"
    | where Status == "Failed"
    | order by StartTime desc
    

    – you can send a request to

    https://api.loganalytics.io/v1/workspaces/{workspaceId}/query?query=LogicAppWorkflowRuntime%20%7C%20project%20_ResourceId%2C%20WorkflowName%2C%20OperationName%2C%20StartTime%2C%20EndTime%2C%20Code%2C%20Status%2C%20Error%2C%20RunId%2C%20WorkflowId%2C%20OriginRunId%2C%20ClientTrackingId%20%7C%20where%20OperationName%20%3D%3D%20%22WorkflowRunCompleted%22%20%7C%20where%20Status%20%3D%3D%20%22Failed%22%20%7C%20order%20by%20StartTime%20desc

    – where {workspaceId} is a Workspace ID from the Properties blade in the Azure portal.

    In my tests, the response contained details of tens of thousands of workflow runs.

    enter image description here

    Hope that helps.