Azure Iot Logic Component - c#

I have a sensor that collects temperature data and sends it to my Iot Hub. This data must be evaluated. In some cases, the data must be sent to another device. Currently, I have a C# console application that does the job. It subscribes to my Iot Hub and reads the data from my partitions. As far as I understood, there must be an Azure component that should be used instead of a console application. My question is, what component can be used in order to receive data from an IoT device in order to process the data?
Thanks in advance!

Azure Functions is a serverless compute service that enables you to run code on-demand without having to explicitly provision or manage infrastructure. Use Azure Functions to run a script or piece of code in response to a variety of events.
you can utilize it instead of writing in a console app and scheduling it .

Related

Laravel Send a Notification to C# Application

I am looking to create some sort of a function that would send Laravel notifications to C# application. The idea is that whenever a user purchases someone, an administrator is then notified by receiving a notification through a C# application that they would run on their PC. However, at the moment the only way I can think of is by creating a listening server in C# and then just send the data via sockets through PHP. Is there anything else that would be considered a better approach?
Kind Regards,
George
You can build an event-driven system. Your Laravel application will be producer which responsible for send events, and C# application will be consumer. There are lots of options to do it.
I would like to recommend AWS SQS. Also, you can easily create a Lambda, then you can add your newest queue as a trigger. When you do this, you will have a serverless architecture, and you won't worry about the scaling part, AWS handles these stuffs. Also, you can check this. It can be a good start point to meet serverless architecture.

Azure IOT Hub - Monitor Device-To-Cloud communication from 1 device

There are x number of devices in system and y numbers of device owners. These devices are actively sending data to Azure IOT Hub - temperature, humidity, voltage, etc.
These devices have RFID chips inside them that store information about device and I'm working with Xamarin.Forms project that would allow android/iOS users to get this information.
Upon retrieving this information about the device, I want users to be able to see and monitor the device-to-cloud Azure IOT communication.
In similar fashion, I'm working on a web dashboard, where user could just select device from dropdown/selection and do the same thing.
I've tried implementing the
Azure Device Explorer approach, however here's the problem; in Azure IOT Hub, one consumer group can only have 5 clients and once, meaning, if 6 people want to monitor the live device-to-cloud communication, only 5 people will be able to do it. Furthermore, what this example does is - get all incoming IOT Hub messages, query and filter only the information that the user wants to see - which would probably put quite of a load on mobile phones.
So the question is: Is there a way to see live device-to-cloud Azure IOT Hub communication from a single device?
I'm open to adding other Azure services.
The Azure IoT Hub telemetry path (hot path) is a data stream of all devices ingested internally into the default built-in Event Hub or externally via the custom endpoint. To see a telemetry data from the single device, it is necessary to capture a telemetry stream and use a filtering technique for a specific data. In other words, the telemetry stream must flow transparently in the stream pipeline without any latency and the capture point will hold a copy of the telemetry window.
This warm path is close to the real-time (hot path) and it can be configured from 1-15 minutes.
The following screen snippet shows an example of the warm path using an Event Hub feature such as Capture. Note, that this feature is not in the Azure IoT Hub, so that's used a custom endpoint with an external Event Hub:
Once we have a telemetry warm path (stored in the Blobs, for example each minute), we can query a device messages, twin changes events and device lifecycle events based on the time, value, etc. by user request, eventing or trigger.
I am working on a similar project, we developed a web app with back end database. this db stores all the iot messages as it comes in, web app send the push notification via azure notification hub to the mobile clients interested about a device. All the business logic and operations is written in the web api project.
Mobiles directly do not communicate with IOT, they communicate via api to get the information from db, and using push notification helps to keep everything real time.
we are using azure functions for reading message from iot as it comes and process.

Azure Service Bus - Multiple topics?

so a brief summary of what Im working with at the moment :
Im deciding whether I can do this with 1 topic vs needing N topics and both with the relevant metadata/filters.
I have 3 pieces pretty much; a socket server (worker role) of which units in the field connect to, Azure Service Bus messaging and finally a web app.
The user can queue commands to be sent to devices via the web app but we need to be able to hold messages in the queue until the device comes online of which it will then get all the messages. This is where I am confused...
I was initially working along the lines of dynamically creating 1-9999 topics (limit of 10 000 topics can be created, so using last 4 chars of serial) at the web app on messages being queued. Will then have the devices full serial within the metadata. This way as devices connect to the socket server I can create N subscriptions with specific rules and shut them down when the devices disconnect.
But now I'm wondering if I could just have 1 Topic and place all the logic within the metadata?
I am very new to SQLFilters with service bus so any help would be greatly appreciated :)
Good question! First of all, i should say that i would use IoT Hubs in your situation which is the "queue"-like service optimized for IoT scenarios, management and commanding included. Or Event Hubs, but they are less command pattern optimized.
1) Event Hubs
2) IoT Hubs
The first one is for scenarios that are more events-oriented. What i mean - to implement the management of the device from the backend will be more complex with the Event Hubs and less complex with the IoT Hubs.
I would highly recommend you to take a look at these services, because Service Bus is the great service, but the listed services are more IoT-oriented.
From the architecture standpoint, recently Microsoft published the IoT Reference Architecture whitepaper that you may download here. It has the recommendations, services, best practices etc that may be used for the Azure + IoT projects from the Microsoft point of view.
Another helpful resource could be http://azureiotsuite.com . It is the reference IoT architecture implemented. So, if you click on the Create, you will have one of two reference architectures (remote monitoring or predictive maintenance) in your Azure subscription and you will be able to review all of the flows.
So, i would recommend to consider to use IoT/Event Hubs instead of the SB Topics/Queues because in the IoT field, the service that is optimized for these workloads should perform better than non-optimized initially.
Second, you did not specify how you connect your devices to the Worker Role, so as i saw there is a good library for doing that called SuperSocket.
So, as i see your solution architecture may looks like:
Device 2 Cloud:
Devices => Gateway (SuperSocket or whatever) || IoT Hub => Device Registry (see links specified above)
Cloud 2 Device:
User Interface => IoT Hub with registered device => Device
Device Registry is more convenient way to do the IoT flows than transferring IDs or etc. Dynamic creation of entities has some downsides - imagine, if creation command will return timeout error, for example. Better to use optimized services, i believe.
When the device is offline, it will not poll the queue. Messages have some retention time before they will be stalled, that is the built-in mechanism.

Continuously sending sensor data to SignalR hub

I'm running Windows IoT on a Raspberry Pi.
After I turn on my Raspberry Pi and Windows IoT starts up, I want to automatically begin reading sensor data from a serial port continuously, and also send the data to a SignalR server/hub continuously. I don't need any UI.
I'm new at UWP apps. Is it best practice to use a headless background task for doing it? But how can I make sure, that the data reading and sending interval is not too long (~1-20ms)? Because I want to use a SignalR client to send the data near real-time.
First you should take care of the size of the package.
Maybe you should also think about using Azure IoT Hub. Azure IoT Hub is build exactly for scenerios like yours, receiving extrem high amount of sensor data in near real time from many devices. And it is highly scalable, and can be used from any client platform.
Here you find documentation, backgrounds and samples: https://azure.microsoft.com/en-us/documentation/services/iot-hub/

Need ideas how to build push notifications service C#

I need help in building push notification service on windows server, to send notifications to android phones.
By now I can send notifications but I need some automatic kind of thing that will handle huge numbers of send requests.
At the moment each Registration ID of device, that installed application, sent to the App Server that stores it in SQL Table. DB itself has table that creates all push notification content for each Registration IDs.
The main goal is to create Service, that will run on the App Server where Database exists, its purpose will be to listen to DB notification table and send them instantly to the client device. The problem is to handle thousands of notifications to be sent as fast as possible.
Do anyone have any ideas how to implement it in the best way?
Use Windows Azure Notification Hubs
You can look into Mqtt.
you can also see how to use mqtt with c# here
You can use multiple technology for the same.
Latest is SignalR
However you can try your hands on https://github.com/Redth/PushSharp as well
Thanks
Nipun

Categories