Unfortunately Logic Apps do not provide an easy option to view the contents of a message unless you go through each log entry and view the outputs as shown below.
However there is an alternative method using Log Analytics which comes with Operations Management Suite (OMS). By using Log Search you can search for specific property values within your messages. Below is an example of searching through the diagnostics log of a Logic App for a particular JobId and the results using OMS.
To start using this feature we need to setup OMS first using the steps below.
1. In the Marketplace search for “Log Analytics” and select.
2. Create the OMS Workspace using a suitable name and resource group.
3. Next we need to add a storage account for the Logic Apps to store diagnostic data. From the Marketplace, search for “Storage Account” and select it.
Create the storage account by providing a name and leave the “Account kind” as “General purpose”.
4. Once the storage account is created, we need to link this to the OMS Workspace. Click on the Log Analytics resource that was created in step 2 as shown below.
In the properties blade, scroll down to the “Workspace Data Sources” and click on “Storage account logs”.
Then click the plus sign to add a storage account. Choose the storage account you created previously.
After you have chosen the storage account, select the “Data Type” and chose events. Then click “OK” at the bottom of the page.
Now that all the plumbing has been configured we can turn our attention to the Logic App. For this example we are going to create a simple logic app that receives a purchase order and sends it to RequestBin and then returns a status code of OK.
Here is an example of the purchase order we are going to post to the Logic App.
{
"CustomerCode": "CUST1000",
"Lines": [
{
"LineNo": 1,
"Price": 68.25,
"ProductCode": "PRD1100",
"Qty": 1
}
],
"OrderNo": "1000",
"Total": 68.25
}
Once we have created the logic app, select code view to add our custom tracked properties on an action. I want to be able to search for orders using either the OrderNo, CustomerCode or the Total order value.
To do this add the highlighted “trackedProperties” section to the action, specifying the attribute name to search on and the path in the message to obtain the value from.
Now that the logic app has been created and saved, we need to turn on Diagnostics for this Logic App. Under the Monitoring section of the Logic App, click on Diagnostics and then Diagnostics Settings shown below.
Set the “Status” to On and check the “Archive to a storage account”, select the storage account that was provisioned previously and the retention periods to what you require.
Now check the “Send to Log Analytics” and select the OMS Workspace created before. Then click the Save button.
Everything should be good to go now. Use something like PostMan to start sending test messages to the Logic App. After a few minutes you should see the tracked properties and their values being written the blob store under the storage account and a container called “insights-logs-workflowruntime”
If you keep drilling down into the containers that matches your logic app name, you will see a file called “PT1H.json”. Inside the file you will see the entries for the tracked properties.
To use OMS to search on on of your properties, click on the Log Analytics under your logic app.
Once the blade opens click on the OMS Portal link which opens the portal site. On the portal site, click the icon “Get Started”. Then under “Data” and “Custom Fields” you should be able to see your custom tracked properties. Take note of these field names as these will be used in the search query.
Now click the Search icon symbol on the left navigation pane and enter the following query “Type=AzureDiagnostics resource_workflowName_s=Orders” into the search box and then click search. Note it can take a few minutes before the data turns up in OMS if you just submitted a message to the logic app. The query will list all logics that have been triggered with the Logic App name called “Orders”.
You should get a list of all the triggers related to the “Orders” logic app as shown below. Here I found 118 events in the last day.
You can narrow your search down further by modifying the search query. Searching for orders with an order number equal to 1004, you would enter this into the query field “Type=AzureDiagnostics resource_workflowName_s=Orders trackedProperties_OrderNo_s=1004”. This will display the records matching the order number.
Also by left clicking on the ellipse (…) next to each field brings up another context menu to provide more filtering options.
In conclusion, by using OMS, it provides the ability to search for tracked properties, save common queries and create custom dashboards. I encourage you to look at all the features available in OMS as we only touched the surface here in this post.
Enjoy.
Like this:
Like Loading...