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 https://sunrise-sunset.org/api
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
Here I’ve set the LogicApp to run every 1 day at 10 UTC which is 5am my time.
Next I get my sunrise and sunset data formatted 0, which I’ll take about below.
I then use Parse JSON after having given it a sample payload to generate the schema.
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 https://github.com/scautomation/SolarEdgeProject/blob/master/logicapps/dailysunrisetime.json
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.
Hi, I’m Billy York. I’m a Cloud and Datacenter Management MVP, specializing in monitoring and automation. Here you’ll find posts about AzureMonitor, LogAnalytics, System Center Operations Manager, Powershell, Hyper-V, Azure Automation, Azure Governance and other Microsoft related technologies.