Tracking business data in Azure Functions using Atomic Scope - Atomic Scope

Tracking business data in Azure Functions using Atomic Scope

Hariharan Subramanian


Category: functional monitoring

Posted: October 1, 2018

Atomic Scope is a functional end to end monitoring solution for integration scenarios. It helps you to track data from  Azure services such as Logic apps and Azure functions. It also allows you to track data from BizTalk components. Hence hybrid integration scenarios can take real advantage of the atomic scope to get an end to end view of their processes. 

Azure Logic apps will have Atomic Scope connectors to track activities. These connectors internally call Atomic Scope azure functions. If your integration solution has Azure functions, you will have to call Atomic Scope functions to track the activities. 

In this article, I will explain how we can track data into Atomic Scope from azure functions using a rather interesting bitcoin tracker scenario. 


People are using many approaches to keep track of bitcoin prices in the market. However, most of them are unaware of the exact time when the prices of the currency drop or increase. In our scenario, we will use a couple of core functionalities of Atomic Scope, which are tracking business data and query based monitoring to track bitcoin price and get alerted when it fluctuates. 

The end goal is to track the data and alert the user if the price of the coin is below the target value or higher than the target value.

First of all, I already have an Azure Function that monitors the Bitcoin prices and logs the price to Azure Function Logs if the price is lesser or higher than some value.

The Azure Function contains two stages. Each stage performs an operation on data. The stages are

  • Get Price
  • Track Coin Price

Getting price data from Coin Desk API

The above function will log the price of the coin if the price is higher than the specified value and also we will check the Function logs. Let’s modify this function and track the data using Atomic Scope.


Azure Functions available for Atomic Scope

Atomic Scope provides the below Azure Functions.

  1. Start Activity

    This is the first step in starting an activity to push data inside Atomic Scope.

  2. Update Activity

    The update activity function is used to update the object created in the StartActivity with the parameters provided.

  3. Archive Activity

    This can be used to archive the message body at any point of time using the AS-Archive Message Header as true.

  4. Log Exception Activity

    The Log Exception Activity is used to log an exception on a specific stage using an exception message and exception code.


Before posting the message body to Start Activity API, there are a few mandatory parameters for all the Atomic Scope API’s. All the mandatory parameters are should be pass as Header values.

So, these header values are the values which are needed to be configured from the Atomic Scope portal which is needed to track the data.

Configuration and corresponding Header Values

  • Business Process Name – AS-BusinessProcess
  • Business Transaction Name-AS-BusinessTransaction
  • Stage Name-AS-CurrentStage
  • API Resource ID (for localhost) – AS-ResourceId
  • Resource Group Name (Azure Function) – x-ms-workflow-resourcegroup-name
  • Subscription Id (Azure Function) -x-ms-workflow-subscription-id

Note: Function App settings from the Azure portal can have mandatory headers or you can pass these header values from the received request.

Function App Settings:

The resulting content from the Coin desk API is sent separately as MessageBody and MessageHeader.

var activityContent = new ActivityContent()
MessageBody = httpContent.ReadAsStringAsync().Result,
MessageHeader = httpContent.Headers.ToDictionary(s => s.Key, s => s.Value)

We have to perform the following operation at each stage. However, I have demonstrated for one stage. 

Calling Start Activity

Similarly, the Start Activity response will contain the MainActivityId and StageActivityId which are mandatory to be passed to the Update Activity function.

Calling Update Activity

                We need to send the response of Start Activity as headers or parameters to the Update Activity function. So, Let’s add the response as headers with the flag to Archive the message inside Atomic Scope and call the Update Activity Azure function.

Thus, for all the stages the final code will look like

Send notification using Query Monitoring

Furthermore, we will now configure Atomic Scope to send a notification to the user based on the tracked price of the data. As a result, If the price of the coin is less or higher than some value, we send the notification to the user.

From Atomic Scope portal, we configure a search query repeatedly for a period of every 15 minutes if the price is greater than our desired value.

Hence, the above screenshot illustrates that we have configured an Alert based on Query `USD > 700 and GBP<6000`.

As a result, it will send the notification based on the configured notification channel. Here, we have configured Microsoft Teams notification.

Therefore, In the configured channel we can see a notification like this with our Tracked data.

You can also see the tracked data and its stages in the Atomic Scope portal UI.



                Hence, Atomic Scope is highly useful in tracking the data and monitoring them based on Business workflow. Finally, You can easily integrate Atomic Scope into your Business workflow for BizTalk, Azure or any custom API’s that you use. Keep an eye on Atomic Scope blog for more realtime scenarios using Atomic Scope.