Where ya’ been, dude?

Well, given that it’s been over two years since I posted here, you’re probably wondering where I’ve been. Or maybe not. Hell, you may not have even noticed I’ve been gone. But I’m going to tell you anyway!

Short Answer: I retired and rode off into the sunset

Longer Answer: Last December (2022), I (early) retired from Microsoft. After nearly two and a half decades at Microsoft, I was fortunate enough to be in a financial position where I could walk away and spend some more time with my (at the time) college-bound daughter, my aging parents, and my wife with our newly empty nest.

It’s been an incredible blessing to be able to take on a slower pace of life and focus on the home life and recharging the batteries after the “dog years” (despite how great they were!) of working at Microsoft.

I am doing some part-time work/consulting on the side, so I’m still doing some technical stuff, mostly broadly Azure focused. But I’m no longer doing any direct IoT or Azure Digital Twins work.

I started this blog because, in trying to solve some complex customer questions/issues in our Microsoft’s IoT Platform, I obtained some obscure and valuable knowledge that really wasn’t in our Microsoft’s ever evolving documentation. So, I felt like this blog added a lot of value. In fact, it still gets a couple dozen hits per day with NO SEO and no new content.

But the broader Azure areas I’m focused on in my part-time/consulting role are more well-trod (and documented) than IoT was back in the day, so I don’t know if I’ll keep writing here anymore or not. Maybe if I figure out something nobody else seems to know, I’ll put something down. I just don’t know yet. And since I’m (semi-)retired now, the odds are not in our favor.

Or maybe I’ll morph it onto writing about a totally different area. Some possibilities:

  • Home Automation
  • DIY – electrical, plumbing, carpentry, etc
  • Mustang restoration
  • Alabama Crimson Tide football and why it’s so awesome 😉
  • Ways to survive being retired and home full-time with your wife and not anger her into a murderous frenzy! <– this is still very much a work in progress!!

Thanks for all the support of my content. The popularity of this content, at least internal to MSFT, actually helped earn me my last promotion before I retired. I appreciate you all, and may we meet again, in this life or the next!

Steve

Monitor IoT Edge connectivity with Event Grid

Hi!  Long time, no see.  It’s been a few months since I posted here.  I won’t bore you with the many “I’ve been busy” excuses (but I have!).  Anyway, enough assuaging my guilt over not having shared with you guys in a while.   Let’s get to why you came here (since google.com probably sent you)

One of the frequent questions we get related to any IoT device, but especially IoT Edge is “how do I know if my IoT device/edge is up and running and talking to IoT Hub?”  I was recently researching this topic for a customer and ran across some cool stuff.   I even did a quick little sample/demo I’ll share at the bottom involving IoT Edge and Microsoft Teams. 

IoT Edge/Hub and Event Grid

As you may know, IoT Hub integrates with Azure Event Grid.  Azure Event Grid is a fully managed event routing service that uses a publish-subscribe model.  Event Grid integrates with a bunch of Azure Services (a pic is on that link above), including IoT Hub.    As shown from the list below, stolen from that same link, IoT Hub publishes several event types to Event Grid.

  • Microsoft.Devices.DeviceCreated – Published when a device is registered to an IoT hub.
  • Microsoft.Devices.DeviceDeleted – Published when a device is deleted from an IoT hub.
  • Microsoft.Devices.DeviceConnected – Published when a device is connected to an IoT hub.
  • Microsoft.Devices.DeviceDisconnected – Published when a device is disconnected from an IoT hub.
  • Microsoft.Devices.DeviceTelemetry – Published when a device telemetry message is sent to an IoT hub

Note that Device Connected and Device Disconnected events will be raised when the devices connect or disconnect.  That can be an explicit connection and disconnection, or a disconnect after a certain number of missed ‘heartbeats’, meaning the device or network may have committed seppuku (not to be confused with Sudoku) .  You can set Event Grid subscriptions to these events and then respond however you want to (Logic Apps, Azure Functions, Text, Email, etc)

So, what about IoT Edge?

Ok, Steve, but google sent me here because I searched for information about monitoring IoT *Edge*connectivity.  If it pleases the court, are you going to talk about that any time soon?

Yes!  The reason this is relevant to IoT Edge is that the connection/disconnection events not only work for IoT end-devices, but it also works for IoT Edge modules!   So, leveraging that, you can tell if any of your IoT Edge modules disconnect and don’t reconnect (did they crash?) or also if the IoT Edge runtime itself loses connectivity (crash?  network issue?) by looking for those events for the $edgeHub and $edgeAgent modules. 

Ok skippy, prove it!

Fine!  I will…   The IoT Hub/Event Grid teams have a nice little example of using the integration between IoT Hub and Event Grid to persistently track the status of your device connectivity in a CosmosDB database, via a LogicApps.  It will have a record for all of your devices, and their last connect/disconnect time.   It’s a pretty nice little sample and could be the beginning of a connectivity monitoring solution  You can build a UI, have it pull the status from CosmosDB, etc.

Check it out if you have the time or inclination.

However, I was too lazy busy to create a CosmosDB, stored procedure, UI, etc.   So I took the quicker way out.  I created a Channel in Microsoft Teams and, each time a device/module connected or disconnected, I just post a message to the channel.

I basically followed that article and all the pieces of it, except everywhere it referenced the stored procedure and CosmosDB, I just instead leveraged the built-in LogicApps connector for Microsoft Teams, which is super-easy to use.

The result is shown below.  I have a raspberry pi running IoT Edge sitting on my desk.  It has a SenseHat accessory in top of it and was running a module that I wrote that talks to it (uncreatively named “sensehat” – they don’t pay me enough for naming creativity).   At about 10:55 local time, I reached over the yanked the power plug out of the raspberry pi.  2-3 minutes later (after some missed heartbeats), viola, I got a post to my Teams channel telling me that both my module (sensehat) as well as the Edge runtime ($edgeHub and $edgeAgent) had disconnected.   (rpihat2 is the device name for my IoT Edge device)

IoT_Hub_Event_Grid_Teams

(full disclosure – I made ZERO effort to make the message look pretty)

I could just as easily, via LogicApps again,  have leveraged SendGrid, Twilio, etc to send me email alerts, TXTs, or whatever for these events.  If you do use Microsoft Teams, you can set alerts on the Channel when new events are posted too.  If you use the mobile app, you even get push notifications.

I didn’t write step-by-step instructions for doing this, as I hope it’s not too hard to follow the Azure IoT team’s cool instructions above and just substitute Teams/SendGrid/Twilio, etc for the output..   but feel free to let me know if I need to do step-by-step.

Leave a comment and let me know if this, or any of my other content, is useful (or if you need/want step-by-step instructions)

Enjoy,

–Steve

Azure IoTHub Auto-scaling

For my inaugural post, I figured, just to have it in one place, I’d revisit something I posted a few months ago on the Azure.com IoT blog.  In fact, doing this is one of the things that prompted me to start this one…   Anyway, a frequent requested feature for Azure IoT Hub is the ability to auto-scale the IoT Hub when you approach your message limit for the day.   It’s a feature that is definitely on our roadmap, but IoT Hub doesn’t natively support it today.   This blog post on azure.com and accompanying sample show you an example solution of how you can do it today.