Create Custom Log Analytics logs with LogicApps

As with anything in Azure there are multiple ways to skin a cat. We can send logs to our Azure Monitor Log Analytics workspace with powershell. Or we can use a powershell based Azure Function, however, in this post I’ll show you how to grab data from an API and use that data to create custom Log Analytics logs with LogicApps. Using a LogicApp we can do this pretty much without writing any code.

I’m presently working on a personal project where I’m collecting a bunch of data. One piece of data I need is the sunrise and sunset times for my location. To do this I’m using the Sunrise Sunset API from here


LogicApp Overview

much like Orchestrator, Logicapps are largely GUI driven. This is the overview of what we’re creating in this post. We start with a recurrence to trigger the LogicApp

Custom Log Analytics logs with LogicApps

Custom Log Analytics logs with LogicApps

Here I’ve set the LogicApp to run every 1 day at 10 UTC which is 5am my time.


Custom Log Analytics logs with LogicApps

Next I get my sunrise and sunset data formatted 0, which I’ll take about below.

Custom Log Analytics logs with LogicApps

I then use Parse JSON after having given it a sample payload to generate the schema.

Custom Log Analytics logs with LogicApps

Finally we’ll build the JSON Payload using the Log Analytics Send Data action, much the same way you can in Powershell. You’ll notice I have some extra formatting on the data. This is because times in Log Analytics are UTC time, even if you send it in -5, its marked as UTC. The format=0 from the API eliminates getting the local time, however it caused some other issues with the data by adding unnecessary +00:00 on the end of every time. This caused Log Analytics to not recognize it as a time. You can view the full JSON and import it to your own logic app here

To see example usage of the Daylight log created here you can check out the post I linked to above about UTC time, or here.



2 thoughts on “Create Custom Log Analytics logs with LogicApps”

Comments are closed.