Azure / New / PaaS / Technical

Logic App – Device Synchronisation into Asset Management

The business challenge Entag was experiencing was growth of multiple network devices and vendors, without the ability to simply
synchronise each network device into a unified asset management solution.

To resolve this problem, we looked at using Azure Logic App as our integration platform of choice.

The first challenge was getting a simple prototype which would just insert new assets before trying to create the update or insert logic (UPSERT), to achieve this in Logic Apps.

The first system I looked to tackle this was UNMS in our Azure environment and the below workflow does a couple of items. First, it declares our variables which we need to authenticate each API service, here UNMS and Freshservice.

Logic App flow for Authentication and to get all devices

Once our variables were declared, a simple POST to UNMS generates the session token. This is required for calling any additional API’s such as Get-Devices and creating a variable to hold this token, allowing the Logic App to use it in future API calls later in the workflow. Now we just call the GET-Devices and BAM all of our devices appear!

Now for the prototype, a simple For Each Loop and POST-Asset follows the above workflow, automatically creating the New Assets based upon the results we get the GET-devices. This ensures the solution works and our API’s are all correct with information now getting created in the Asset Solution. However, this is just Creating a New Asset each time it runs which leads us into the simple problem of multiple cloned assets.

Now to improve the Logic App, we need to first check if the device already exists and this is where the fun begins. The limitation of Freshservice’s API is that LIST-Assets is paginated, meaning it will only return 50 assets per page. This causes a problem as we have over 50 assets…Meaning we have to make multiple API calls to return each page wasting our precious 1000 calls per hour limit.

However, Freshservice API has a Search-Asset which lets us filter by three fields- Name, Serial Number or Asset Tag. UNMS each device must have a Name, however serial number or asset tag isn’t mandatory. This means our Logic App will need to make a simple call with the search parameters equalling the name of the device in UNMS.

API Call which search’s asset register for device name

Next we need to create a condition where if the device is returned, PUT-asset to update the asset with the new information or create the asset by using the POST-asset. Simple to do, however, Freshservice return API when a device isn’t in the asset register is still a status 200. Meaning we need to write a condition statement based upon the returned body.

A condition block checks if the body contains {“config”:[]} which is returned when the asset doesn’t exist in Freshservice. To create our if Statement we will just check if this exists or doesn’t exists, hence completing our logic by creating an asset if true or updating the asset if false.

Conditional results

In the end, the UPSERT logic of this Logic App lets us sync our devices from UNMS into our Asset register. A simple recurrence once a week ensures that our asset register gets updated weekly. The great thing about this Logic App is we can template the UPSERT logic for a ton of other uses or systems.

A Solution architect who focuses on designing solutions leveraging telecommunication networks and Microsoft technologies. A strong focus on automating solutions to help businesses focus on their business instead of technology. Enjoys working in the start-up world where business environments are dynamic and skills in developing new business units such as managed services from design, implementation and lifecycle.
Total post: 13

Leave a Reply

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

%d bloggers like this: