One of our friendly Turbo360 customers reached out recently to ask for some advice because they had an issue where Logic Apps were not processing messages from Service Bus but then started working again some time later. They werent sure what had happened or why and wanted to understand how to mitigate their risk for the future.

I love questions like these as it lets me out my integration hat on for a bit and help nudge people in the right direction. I felt this was an interesting one to share so below is what happened.

Scenario

  • There is a Logic App Standard workflow which triggers from Service Bus
  • The trigger polls every 30 secs to check for messages
  • It is running regularly every day for a long time with no issues
  • On the day in question messages had queued up for an hour with nothing happening
  • The Logic App suddenly came to life and processed the backlog
  • The backlog hadnt gotten big enough to trigger the monitoring for queued message count
  • The Logic App never went to a stopped state

The question was why does this happen and why did it magically start working again.

What was happening

We could see in the metrics that the app seemed to go dead with no handles or running threads during the period and also there were no workflow triggers being completed.

Below is a view of the thread count which went to zero.

One of the interesting things is the workflow trigger count dropping to zero is a bit harder to notice because when the app is quiet it drops to a low number anyway but not zero so you cant easily see this on the graph.

Why it magically started working

It happened that the customer was using Turbo360 with the API ping test which pings the Logic App and it had been configured to ping a diagnostic workflow in this Logic App every hour. When this ping test executed it send an HTTP request to the workflow which fired up the workflow runtime and all workflows are loaded into memory.

The diagnostics test passes and its all happy.

As a side effect of this the Service Bus trigger is not activated and starts polling for messages again so the service bus workflow starts processing messages and clears the backlog.

What had happened

In this case the functions worker runtime that Logic Apps is executing in had crashed, the app had not started back up automatically though.

When the Turbo360 ping test executed it started up the app and made everything come back to life.

Proper Fix

The correct fix to prevent this happening is to have always on turned on for the app which is running on an ASE. You can see below the missing setting.

Improving Monitoring

There are a couple of additional things the customer can do to improve their monitoring with Turbo360.

Monitoring Profile Update

We added the Thread Count dropping to zero as a monitoring condition their monitoring profile checks for. This will trigger on the app going off like this again.

App Insights to Monitor for the Log Events

You could query app insights with the below KQL to monitor for the events of the runtime stopping and starting. Below are the 2 messages you are looking for:

  • Starting the worker app with environment name ‘Flow function extension’, Number of cores: ‘2’.Memory: ‘228048896’.
  • Stopped the runtime with environment name ‘Microsoft-Azure-Workflows’.

The below query will identify these events.

traces 
| where timestamp > ago(7d)
| where customDimensions.Category == "Workflow.Host"
| where customDimensions.EventName == "ServiceStarting"
or customDimensions.EventName == "ServiceStopped"
| where customDimensions.prop__siteName == "[Your Logic App]"
| extend prop__message_ = tostring(customDimensions.prop__message)
| extend prop__message_ = tostring(customDimensions.prop__message)
| project timestamp, prop__message_, message
| order by timestamp desc 

We used a KQL query to monitor the log to look for cases where the most recent log event indicates the process has stopped and we can drive an alert in Turbo360 by running this query periodically

traces 
| where timestamp > ago(24h)
| where customDimensions.Category == "Workflow.Host"
| where customDimensions.EventName == "ServiceStarting"
or customDimensions.EventName == "ServiceStopped"
| where customDimensions.prop__siteName == "[Your logic App]"
| extend prop__message_ = tostring(customDimensions.prop__message)
| extend prop__message_ = tostring(customDimensions.prop__message)
| project timestamp, prop__message_, message
| order by timestamp desc 

Governance Monitoring to Check it doesnt happen again

We can finally use a resource graph query in Turbo360 to monitor for any other Logic Apps being deployed which dont have always on enabled. This will stop the problem coming up again.

We can use the below KQL to check for this.

resources 
| where type == 'microsoft.web/sites'
| where ['kind'] contains "workflowapp"
| extend alwaysOn = tostring(properties.siteConfig.alwaysOn)
| where alwaysOn == 'false'
| project name, subscriptionId, resourceGroup

Adding this KQL query to Turbo360 means we can have a governance test across all of our environments and raise an alert if the count of apps with always on disabled does not match what id expect.

No Data Monitoring with Business Activity Monitoring

The customer also has the added benefit that they are using Turbo360 Business Activity Monitoring.

One of the features they can use in that module is that they can set an expectation of the number of messages they expect to process over a rolling time window. In this case they could raise an error if there was no data processed which would have been another way you can raise this issue to operations.

 

Buy Me A Coffee