Generate Logic App Standard run history URL in Application Insights log

This post has been republished via RSS; it originally appeared at: Microsoft Tech Community - Latest Blogs - .

Background

Recently, we only can filter failed runs on workflow level in Logic App Standard and we also cannot filter for specific errors. So this blog is to introduce a different way to generate run history url based on Application Insights logs which can help us to find failure runs based on specific exceptions.

 

Mechanism 

When we directly copy the run history URL from Azure portal, we will find it is very complex with all sorts of different parameters.

After URL decode, we can see the URL contains a Json payload which include quite some workflow information:

Drac_Zhang_0-1683191921499.png

 

Except for the Json content, all the rest parameters (resource id, run id, etc.) we can easily grab from Application Insights logs.

So I tried to remove the fields of the Json content one by one and found actually the portal only need to have the trigger name field (we even don't need to provide the actual trigger name, an empty string also can work).

 

As per the situation, the url can be simplify as following:

https://portal.azure.com/#view/Microsoft_Azure_EMA/WorkflowMonitorBlade/id/[ResourceID]/location/[Region]/resourceId/[RunIDWithWorkflowName]/runProperties~/{"trigger":{"name":""}}/isReadOnly~/false

 

How to use KQL query to generate URL

By default, the Logic App STD is binding with an Application Insights to store the logs.

The first thing, we need to find the Log Analytics Workspace which behind the Application Insights:

Drac_Zhang_0-1683192966032.png

 

Then we can directly run the query to generate run history URL as per your filter, once we have the link, we can right click on the URL and direct to the run history by "Go to link":

Drac_Zhang_0-1683193358601.png

 

We can see it can open the run history page with simplified link:

Drac_Zhang_0-1683194210609.png

 

Sample Query

My sample query is to get all the failed runs and generate the link, you also can add your filter to search for specific exceptions:

AppTraces
| where Message has 'Workflow run ends'
| where Properties.prop__status == "Failed"
| project TimeGenerated, WorkflowName = parse_json(tostring(parse_json(tostring(Properties.prop__properties)).resource)).workflowName, AppRoleName, RunID = Properties.prop__clientTrackingId
| join kind=inner (FunctionAppLogs
| where _ResourceId != ''
| top 1 by TimeGenerated
| project Location, _ResourceId, AppName)
on $left.AppRoleName == $right.AppName
| extend id = strcat(_ResourceId, '/workflows/', WorkflowName)
| extend run = strcat('/workflows/', WorkflowName, '/runs/', RunID)
| extend RunHistoryUrl = strcat('https://portal.azure.com/#view/Microsoft_Azure_EMA/WorkflowMonitorBlade/id/', url_encode(id), '/location/', url_encode(Location), '/resourceId/', url_encode(run), '/runProperties~/', url_encode('{"trigger":{"name":""}}'), '/isReadOnly~/false')
| project TimeGenerated, WorkflowName, RunHistoryUrl

 

 

 

Leave a Reply

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

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.