Understanding Azure IoT Edge

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello world and welcome to this edition of tech on fire with blaze i'm blake stewart architect at wentlock today we'll be taking a look at azure iot edge [Music] [Music] hi guys today i'm going to take a look at azure iot edge and this is a product that allows us to do a lot of different things related to azure iot but what it does it allows us to take what azure iot does and moves it a little bit closer to where the devices actually reside so in a way it's kind of like a microcosm of azure in the way that it works with azure iot devices so we're going to basically just look at this from a more conceptual level today and we're going to be looking at it in more depth as we go through a few other videos that we'll be doing on the specific topic now iot edge is pretty straightforward conceptually if we see this diagram here it's basically a gateway for iot devices this camera right here represents my iot devices and what this allows me to do is put a gateway in between the iot hub and iot experience on azure and the actual device itself so that this device can send messages to the iot edge and then that proxies them to the iot hub and vice versa if i want to send messages down to the device i can send those to the edge and then those get sent down to the device so we have that kind of bi-directional communication that we saw whenever devices were communicating directly with azure iot hub now that's not the only thing that is for rather it's designed to be extensible and that's what modules are for and there's a lot of things that you can do with modules but there's an experience i want to talk about first before we talk about modules and that's the kind of gateway experience that you might have with an iot edge now an iot edge can be one of two different kinds of gateway one kind of gateway is that what we call a transparent gateway and that's basically where a device could either talk to the edge itself or could talk directly over here to an iot hub and if you're using sdks the sdks are smart enough to figure out if i'm talking to an edge and that's based on the connection string or i'm talking to an iot hub but regardless of its whether it's talking to this or this the communication protocols and all the functionality work basically the same way and i can then use the io2 edge or iot hub with the sdks without having to change any of the code i just simply change the connection string in one case it'll do this model and in the other case it'll just do a straight connection up to iot hub which is what we've seen thus far the translation gateway however is a little bit different and this is designed for devices that can talk to iot hub and in that context this device over here has a communication protocol that iot hub does understand so what the iot edge will then do is have a module right here that this device thing can connect to and then once that module is there this device can connect to that module and then this will translate whatever telemetry this device is sending into something that the iot hub can understand and then it will send it on to the iot hub and then vice versa if the iot hub sends something down from the cloud and i have that translation module it can then have the ability to put that into a protocol or a kind of message that the device can understand behind the gateway and that's why we call it a translation gateway and that's also used for security context as well in the event that a device can't secure itself against azure iot hub or in that regard but that's not the only thing that modules do fundamentally these are pretty diverse so they're based on docker images so you can kind of do whatever you want to with it but there's a couple of things that you can do with them beyond just the kind of things that we've talked about already with a message translation you can do message filtering that's a common approach that people use for modules what that allows you to do is send messages from a device up to a module here and then what that will do is it'll apply some filters to that message and it will only send the messages that matter up to the cloud because this might be emitting all kinds of telemetry here and rather than send all that over the wire over the internet right it will just filter that message and then send out only what it needs to the cloud and then the cloud can process that accordingly another common thing that these are used for is ai so what you can do with that case is have a module that is trained on azure so you have an ai model over here and the ai model is then pushed up to a module right here and then device telemetry is processed by that module and it might be enriching it it might be transforming it it might be filtering it based on whatever's in that ai and then the results of that are sent up to the iot hub as telemetry after the ai model has been applied to it and the last thing it does is it provides some kind of extensibility to the iot edge beyond some of those capabilities that we talked about right there so there is the case that you might want to set up some kind of database that is a little bit closer to the devices that that might allow the devices themselves to have a local database without having to connect to the cloud and that local database would be installed as a module so you could install something like a sql server database as a module on your iot edge and then have your devices have a local database where they can write and read data from without having to use something like azure sql or something else like that so i'm here in the azure portal and i wanted to create a device it's pretty straightforward now i've got a device here that i called camera one i've used in other demos i'm going to repurpose it for this demo but i have this other menu here for creating iot edge devices now an advice is basically just the appliance that you're going to be using for your iot edge now what this does is is it creates a registration for that and what this allows you to do is have devices that are managed by the iot edge or you can manage other iot edge devices from an iot edge so it's pretty robust in what it can do in any case if you go over here to your dev add an iot edge device you can choose the authentication type which you can use symmetric keys or you can use certs right here and then you can select the the child device that you want to manage this when you create it you can also add those later if you so choose and once this creates it's going to look like this right here and this gives you the ability to go back and add new devices to it if you so choose and it also gives you connection streams for your particular iot edge this is important because this is what you'll need to have available whenever you go to create the device and provision the actual appliance wherever it might be now i've already done this and i'm going to link instructions i'm going to do this in the video description below it's pretty straightforward you basically just need a linux box it could be a virtual machine it could be a physical box and you run some install packages and then you run a script that will basically just use the connection here and it will connect your iot deployment back up to the cloud and once you've got that deployed you're ready to go now there are ways that you could uh and harden that device and you could do a lot of different things to it how you've got it set up but the basic instructions for setting this up for you know even a production environment are available online which i'm just going to link to that and let you go through that but once you have that set up you'll have a command line that you can use on the device which looks like this now ssh into the box that i'm going to be using for this and i've called it iot edge so this is just an ubuntu virtual machine that is basically running uh iot edge runtime and so i created at ubuntu virtual machine i ran through the script and now everything is working according to plan so this is the iot edge cli that that allows you to do things against it so you can do run checks on this now this one's not production oriented because i this one's going to tell me that my storage is for my device is on the file system which you wouldn't want to do that you'd want to store that off device typically in a file share or some other mechanism uh so in the case that this device was destroyed or something happened yet that could be recovered and you could then use that to restore the device after you reprovision it but otherwise the device storage is about the only thing that's keeping this from being production ready and that's just what this is telling me here and that's so i just ran a command that said checks so another one that's very useful is just getting the status so if you go to iot edge and then you go iot edge system and then you type in status that's going to show you the status of your device and it's going to have is the edge running is the identity running is the key running asserts and all these other daemons that it spins up as part of its deployments another thing that you can use and we'll look at it later is logs for modules which is basically the modules that we're going to have running whenever we deploy some of those modules i'm going to do a whole video on modules and we're going to look at how we can use the logging mechanism for that but you can also get the system logs as well so if i go iot edge system i can do logs right here and it's going to show me the system logs for this particular item right here and so this is a lot of ways that you can just see what's going on on the device and you can see what's happening in the context of more of a dev environment or if you need to connect into something for diagnostics purposes iot edge is the cli utility for doing all of that different kinds of things that you're going to be doing at the command line now once you have this up and running using it is pretty straightforward so i'm going to go over to some code and i'm going to look at the code just to show you how i provision the code and i'm going to show you how it works against this device and then we're going to run the code and see what happens so this is some sample code that i basically just took from the sdk sample kit and i want to run this code against my edge device now basically the only thing that i really need to change about this code is the connection string other than the default connection string that you get from the azure portal or that you can generate is fairly straightforward so in this case a default connection stream is going to look like this i don't have the key here but you can see that it has the host name the device name and then the shared access key for this now if you're using search of course you'd be using a cert file for authentication but in case the connection string looks like this right here and then that's just going to tell the sdk how to connect to this now because i'm using a transparent gateway i can embed the gateway host name in my connection string and then the sdk is smart enough to figure out to connect to the gateway host before it connects to the iot hub and then the gateway connection string will use the same shared access key and all the other same parameters that my connection string has the only difference is that this gateway host name is now a part of the connection string that i'm going to have here and i put the ip address for my iot edge device right here in this connection string so that way it knows how to connect to my iot edge and then because it's a transparent connection it's just going to forward that data onto my iot hub and in that case i can then use it just like i could on azure now to use this what i'm going to do is i'm going to basically start this up and it's going to start emitting telemetry and that's going to go away by way of my iot edge device right here and then i'm going to connect up a listener to a service bus that i have waiting on the other end that's going to be listening for whatever messages my device right here is going to be sending so here is the command prompt that i'm going to be starting up with my simulated device right here with so i'm going to go nodeindex.js on this and this is going to start that particular code that we just looked at using the connection string i still have my edge up and running so it's going to connect to that and so it's now sending messages to the azure iot edge and then that's sending up to iot hub and then that's coming over here to my device listener which i'm just using the service bus explorer to listen to these and so this is uh the end-to-end demo that i'm really looking at here so this is sending a message going to iot edge service but up to iot hub and then up to a service bus then on to this client right here and it's doing it pretty quickly without much latency so what we're going to be looking at in future videos is modules on how i can use those modules to do things like filter messages which you're going to be looking at probably next week whenever we look at some of those things and we're going to be looking at the some of the extensibility that those modules provide to us if you like this content please consider visiting us online at www.wintelec.com and there you can find about services that wintelec offers including training and consulting services also please consider subscribing this channel by clicking on the subscribe button and clicking the bell icon to get notifications when new content becomes available and also comment down below you can also follow me on twitter at the one mule and also follow intellect on twitter at winnelec now or at whenelect we are constantly posting things about azure related technologies and things related to software development you can also reach us by email at consulting whenelect.com until next time thank you
Info
Channel: Atmosera
Views: 13,574
Rating: undefined out of 5
Keywords:
Id: 9Pe1ZF_KAfI
Channel Id: undefined
Length: 14min 30sec (870 seconds)
Published: Mon Jan 24 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.