Search for runs in Logic Apps with PowerShell

When you have a polling Logic App and most of the polling are “empty”, meaning that no data were found and processed, it can be hard to find the runs where data actually was processed.

It is not fun to search for these processed runs manually and this is where you should think “Let’s do some scripting”.

First let’s check out two runs from the Logic App. The first one does not find any files matching what we are looking for. The output of the action Filter array is empty.

In the other run we got a match on the file we are looking for. The action Create_file is run and that is the action we will use in the script to know if content has passed the Logic App.

To find the runs which actually processed the data you can use this PowerShell script.

The script is based on  Get-AzureRmOperationalInsightsSearchResults cmdlet so Log Analytics and OMS must be enabled, You can read more about how to get started with Log Analytics and OMS in the Microsoft Azure Documentation pages.

Some input are required by the script:

  • ResourceGroup – the name of the resource group where the OMS workspace is located
  • Workspace – the name of the OMS workspace
  • Workflow – the name of the Logic App workflow
  • Action – the name of the actual action within the Logic App
PS C:\scripts> .\Get-RunsWithSpecifiedAction.ps1 -ResourceGroup MyResources -Workspace myomsworkspace -Workflow MyLogicApp -Action Create_file

2018-01-29 21:11:02 MyLogicApp Create_file Succeeded 08586843502256332710196238228
2018-01-29 21:06:01 MyLogicApp Create_file Succeeded 08586843505261018198219360069

PS C:\scripts>

The output from the script includes the datetime, status and the actual runId, which can be used when searching for more details in the Logic Apps runs history or with another script (maybe in a future blog post).

This is one way of doing it, of course you can go in to the OMS portal and do the search but I am too lazy for that, PowerShell scripts to the rescue…