How to filter all the workflow runs that are in running state using logic managment client class and workflowRuns function

vivek singh 1 Reputation point
2022-03-30T19:29:02.593+00:00

I am trying to get the top n workflow runs that has status marked as Running. I am using below mentioned function to fetch the details using azure/arm-logic module in Typescript, but due to some reason status filter is not working I am fetching all the runs irrespective of there status. Please help me to resolve this issue. I looked into the documentation but not able to debug it. Function not throwing any kind of error but its also not fetching right data.

function isProcessorRunning() {  
    return new Promise((resolve, reject) => {  
        const subscriptionId = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";  
        const client = new LogicManagementClient(new DefaultAzureCredential(), subscriptionId);  
        const workflow =  client.workflowRuns;  
  
        const data = workflow.list(Resource_group_name, workflow_name, filter = {"status" : "Running"});  
          
        data.next().then(data =>{  
                             if(data.value.status == 'Running');  
                               
                             resolve('Success');  
  
                         }).catch(err =>{  
                            console.log(err);  
                            reject(err);  
         
    });  
}  

Please find these link for reference - https://learn.microsoft.com/en-us/javascript/api/@azure/arm-logic/logicmanagementclient?view=azure-node-preview#@azure-arm-logic-logicmanagementclient-workflowruns

WorkflowRunsListOptionalParams interface - https://learn.microsoft.com/en-us/javascript/api/@azure/arm-logic/workflowrunslistoptionalparams?view=azure-node-latest#@azure-arm-logic-workflowrunslistoptionalparams-filter

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

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 70,741 Reputation points
    2022-04-07T07:27:50.96+00:00

    @vivek singh Thanks for reaching out and apology for the delay. I believe you might have already resolved the issue. But in case you haven't found the solution and for the community facing the same issue posting the resolution for your issue.

    As you have already shared the document the filter should be of type string as mentioned here. The filter should have the ODATA query as below. For supported filter status values you can refer to this.

      const data = workflow.list(Resource_group_name, workflow_name, { filter: "status eq 'Failed'"});  
    

    Let me know if you are still facing the issue.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    0 comments No comments

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.