Advanced tracking with Logic App and Integration Account

Operating at scale

Once your integration solution with Logic App reach a certain scale and complexity, the vanilla Azure Management Portal, Logic App run history, albeit capable, is not quite powerful enough for IT engineers to service the solution efficiently. It is then time to enable the diagnostics on the Logic App to generate 'WorkflowRuntime' log events which first you can use for alert rules right there in the Azure Management Portal but which also importantly enables to export events to Azure Operations Management Suite (OMS) aka Log Analytics

Logic App Diagnostics Settings

The Diagnostic logs under the Monitoring section of the Logic App tile will then light up. A link to the configured Log Analytics will bring you to both in the management portal Log Search as well as the OMS portal where you can enable easily designed custom reporting or turn on purpose-built solutions. Best of all the whole service is free for up to 500 MB per day and beyond that a very reasonable $2.30 per GB if you upgrade to paid service (pricing may change, see current pricing information here).

For those using B2B connectors - AS2, X12, EDIFACT -, you will greatly benefit from enabling diagnostics on the Integration Account associated with the connectors. Integration Account Diagnostics Settings

There is a dedicated OMS solution for rich analysis of the generated tracking data, to be found in the Solutions Gallery:

Logic App B2B OMS homepage

See more on the Azure documentation for Tracking B2B messages in OMS.

Going custom

Tracked Properties

From within the Logic App you have a simple, quick way of feeding custom tracking data into the diagnostics stream: tracked properties. This is documented in the third part of this section “Azure Diagnostics Settings” and in particular “Tracked properties”:


This works only for content you can express in the Logic App workflow definition language. These tracked properties will be added to the WorkflowRuntime log (as opposed to the IntegrationAccountTrackingEvents for B2B connectors and custom tracking events below).

Custom tracking events

The Integration Account custom tracking events have be to be used if calling from outside the Logic App. And pause for a moment - that's a very powerful thing when you think about the services and applications you may have surrounding your logic app. Imagine for instance that you had a custom store-and-forward service at the edge of your enterprise solution which capture everything going in and out for redirection, load balancing, buffering, troubleshooting and replay scenarios - you can now emit tracking events from that service to the same store as your Logic, as your B2B connectors and include correlation ids to tie the whole flow together across heterogeneous services. Same for your Line-Of-Business application at the core of your solution, you can also emit correlated events from there.

Within the Logic App you have a choice between the simpler LA tracked properties and the more capable Integration Account custom tracking events. If you write your own connector code, it will be more efficient to call Integration Account custom tracking events directly than to do an HTTP action to call the Integration Account - this is what the B2B connectors internally do.

 The Integration Account custom tracking events follow a Json schema documented at:

With a custom record type as JToken, you can track in a single call all the properties you want for an action, following a structure that you define, instead of declaring one-by-one each property as in the Logic App definition language for promoted properties. Also notice that the API takes an array of events such that in a single call an event source can log tens of events with that single network trip. For high throughput connectors like B2B, this enabled to keep a verbose tracking output detailing and organizing information at all levels of the protocol - Interchange, Functional Group and individual Transaction Sets plus each of the matching Acknowledgement messages, generated or received.

With your custom payload you call the tracking API on the Integration Account. The relative URI to track events is /logtrackingevents

This needs to be appended to the Integration Account callback URL.


[caption id="attachment_296" align="alignnone" width="1610"]An example of calling tracking API on Integration Account using Postman An example of calling tracking API on Integration Account using Postman[/caption]

The method is POST, the URL is the integration account’s callback URL where you add the /logtrackingevents method suffix after the integration account id and before the query string parameters (?api-version…).

 The one header you need to have is {"Content-Type":" application/json; charset=utf-8"}

 One optional thing missing at the time of writing this blog post in the MSDN article for the event schema is that at the same level as the “recordtype” and “record” you can have an “error” field containing a “message” and “code” both of type string. This is most relevant when you want to track your custom error events on which you can write specific alert rules. Then it is most efficient with unique error code per live site support situation you anticipate, as you can use the unique error code to trigger specific automated remediation steps or to point operators to specific manual remediation steps/scripts.

Troubleshooting development issues with custom tracking

Here are some of the error you might run into while trying to post for the first time to the tracking API:

Error code: 401 Unauthorized
"error": {
"code": "AuthorizationFailed",
"message": "The authentication credentials are not valid."

=> Error in the authorization query string parameter (e.g. typo, incomplete copy-paste, etc.)

Error code: 415 Unsupported Media Type
"error": {
"code": "UnsupportedMediaType",
"message": "Unsupported media type."

=> Content-Type header is not set to application/json; charset=utf-8

Error code: 404 Not Found
"message": "No HTTP resource was found that matches the request URI 'https://<foobar>'."

=> The URI relative path is incorrect. For instance you have not added the necessary /logtrackingevents suffix after the integration account GUID and before the query string parameters which start with ?api-version=
=> Or, the HTTP verb is incorrect. Use POST (not PUT).