Azure Functions and Logic Apps

I wanted to create a simple Azure Function to make an HTTP GET Request to my website, which is hosted on the cheapest GoDaddy subscription. This subscription is on shared hosting and I don’t have much control over it. The initial load time of the WordPress site is CRAZY slow… in the ~22 second range! After the initial load time I’m seeing anywhere from 5-9 seconds load time. So I thought I’d create a keepalive function to make a HTTP GET Request once every 4 minutes, since the app pool shuts down after 5 minutes of inactivity. At first I created a SUPER simple Python script to do this, and it worked well….. Until it didn’t. I wasn’t home for a couple of days and it stopped working. I was running it on a RPi at home. However, I didn’t have any kind of VPN setup, so I could login remotely to see what the issue was. I thought, heck, I’ll create a super quick Azure Function based on a timer to ping the site instead. That way I can see if there are issues online anywhere I have internet access and potentially fix the issue also.

I did that and it worked well. However, I started to notice some issues… The interval not kicking off every 4 mins like I set it up to do, and some communication service errors. The communication service error I attribute to potentially the sight being down at GoDaddy for maintenance or something similar. The not kicking off every four minutes??? I’m not sure what that issue might be attributed too, minus, maybe Azure maintenance?

I decided to replace all of this with a Azure Logic App. I started looking at an Azure Logic App, since I could easily create a workflow, that I could maintain. For example, I make the request every four minutes, if for some reason, I get a HTTP status code greater than or equal to 300 I can send myself a text message. In addition, it is really easy to hook it up to log to Azure Table Storage. Well there was a bit of trial and error to set it up, but I was able to figure it out in about 10 mins or so….

To insert into table storage the designer wants you to create valid json. The key for me was figuring out how to insert a GUID for the RowKey. See the syntax below:

{
"Body": "Body goes here",
"Headers": "@{outputs('HTTP')['headers']}",
"PartitionKey": "fsnKeepAlive",
"RowKey": "@{guid()}",
"StatusCode": "@outputs('HTTP')['statusCode']"
}

The @outputs sections were automatically created for me using the GUID, but I had to figure out that there was a guid function available in this context and the correct syntax.

In summary, the Azure Function gives a lot of control, but requires a but of coding. The Azure Logic App doesn’t require much “coding” AND provides a lot of features though the extensive list of integrations.

Happy 2018

I haven’t posted in a couple of weeks, so I figure I better get to it. I have a number of things I’ve been working on in the new year.

  • I’ve been watching some Pluralsight videos on Angular. I’ve learned Angular a couple of years back and it has changed a bit, so time to pick it up again.
  • I’ve started learning about docker. I created a simple docker application, ran it on my Mac, my PC, and then ran it on a simple Azure Ubuntu VM.
  • I created a new keepalive “service”. I had one running on my RPi at home, but when I was away for a couple of days… I realized it had stopped working. I don’t have a personal VPN into my house to figure out why, so I decided to create a super simple Azure Function to do the same thing. That way I can monitor and maintain it anywhere.
  • I’ve also been busy 3D printing for my son’s cub scouts. I created a blue mustang pinewood derby car body!
    • In addition, I’m going to be 3D printing their names, pack number, and year for their Arrow of Light plaques.

On top of all of this I’ve been studying various algorithms from my college days as these days hiring employers like to test you’re thought process by giving you academic problems to solve and see the thought process as you go through to solve them.

I’ve been pretty busy and since it is a new year, I want to make some goals for 2018. These are not set in stone, but goals I would like to achieve. These are not in any order.

2018 Goals:

  • Complete at least one online course a month about technology. Be it to learn a new language or just to improve my craftsmanship.
  • Listen to two technology podcasts a week.
  • Listen to one book a week (I use Audible a lot).
  • Play tennis at least once a week.
  • Drink no more than one mocha a week.
  • Stop drinking soda (unless it is with rum on the weekends).
  • Workout three days a week for at least 30 minutes at a time.

I think these are doable goals and just the start, I’d like to add more, but I also want to make sure I make reasonable goals.

Like the title says… Happy 2018!