My device uses a standard MQTT library (not the azure-device-sdk) to connect to my IoT hub. Unfortunately, it expects message payloads (device configurations, direct method invocations, etc.) to be represented in binary (which is contrary to IoT hubs Json-first approach) and to be encrypted and signed on the application layer.
Is it somehow possible to "augment" the processing pipeline of an IoT hub with custom steps (e.g. register an Azure Function that is invoked before a message is sent to the device)? I've read about Microsoft's Azure IoT Protocol Gateway (https://github.com/Azure/azure-iot-protocol-gateway) but it seems kind of immature and not well-integratable with serverless architectures.
Related
I'm tryng to develop an high-frequency message dispatching application and i'm observing for the behavior of the SDK about message reading from the ModuleClient connected to the edgeHub by using "MQTT on TCP Only" transport settings.
Seems that there is no way to read multiple messages at time (batch) from the edgeHub (I think is something related to the underlying protocol).
So the result is that one must sequentially read a message, process it and give the ack to the hub.
Does exist a way to process multiple message at time without waiting for the processing of the previous?
Is this "limitation" tied to the underlyng protocol?
I'm using Microsoft.Azure.Devices.Client 1.37.2 on a .NET Core 3.1 application deployed on Azure Kubernetes (AKS) by using Azure IoT Edge on Kubernetes workload.
You are correct, you cannot use batch in MQTT protocol. This is a limitation tied to IoTHub when using MQTT Protocol.
IoT Hub only supports batch send over AMQP and HTTPS at the moment.
The MQTT implementation loops over the batch and sends each message
individually.
Ref: https://github.com/Azure/azure-iot-sdk-csharp
Suggest that you add a new feature request, if need IoTHub to support batch when connecting using MQTT: https://feedback.azure.com/forums/321918-azure-iot-hub-dps-sdks
I have sent messages to Azure IoT Hub device called dev1, I could not see the messages in IoT Hub but, I can read the messages only when the client application is online when the sender is sending messages. Azure IoT Hub supports only online messaging and no offline messaging? If offline message support is there, where are these messages are stored, I couldn't see the messages in IoT Hub.
When I configure the custom endpoint as Blob storage, I can see messages are stored in blobs.
Please help me on this.
Thanks in advance
If I understand correctly you are looking for reading the messages directly on IoT Hub portal UI. If that is the case, then one of the things which you can make sure about D2C Messages in IoT Hub portal (UI perspective) is looking at the Metrics chart (See below Images). For reading the actual payload you have to make use of in-built Event Hub endpoint or routing to other supported endpoints.(You have already mentioned in your scenario-Client/Sender applications, So I think you have already known this method of reading messages)
The Metrics chart atleast tells you that the messages are received in IoT Hub (UI), you can't read them on the Portal(UI).
IoT Hub is built on top of Event Hubs, and that's where your messages will be until you start reading them. They will be stored there for 1 day by default, although you can change that up to 7 days. For more information on retention, please read this page.
I'm using Azure IoT Edge in transparent gateway mode. Now I would like to add a property to any message from leaf devices that gets passed through the Edge gateway, that basically contains the Edge device id (or its hostname etc). Thus allowing to trace the message flow.
Is this somehow possible? I already tried to put a custom module in between which I would just route all messages through:
"fromRaw": "FROM /messages/* WHERE NOT IS_DEFINED($connectionModuleId) INTO BrokeredEndpoint(\"/modules/taggingmodule/inputs/input1\")",
"intoUpstream": "FROM /messages/modules/taggingmodule/* INTO $upstream"
But doing this I lose the "transparent" message-passing. Any messages that are then received in the cloud IoT Hub appear to come from the Edge device instead of the leaf device.
In this way, it is not what the transparent gateway was designed.(Ref: here.)
The gateway simply passes communications between the devices and IoT
Hub. The devices are unaware that they are communicating with the
cloud via a gateway and a user interacting with the devices in IoT Hub
is unaware of the intermediate gateway device.
To workaround this issue, there are two options:
Based on what you did for now, embed additional information in messages that generated on the leaf device to identify where the message comes from.
Remove custom module in the transparent gateway. Add Edge device id (or its hostname etc) in leaf device message.
Is the use-case of the ServiceClient to send messages to devices?
ServiceClient supports only amqp messages. Documentation for Azure Devices namespace says "Transport types supported by ServiceClient - Amqp and Amqp over WebSocket only". In code the TransportType exposes only Amqp. Would it be changed in the future?
If the ServiceClient is been used for C2D messages, why in this answer, is written that "For ServiceClient, you need Azure IoT Hub connection string, not device connection string"?
What is the performance's impact and resources' utilization, if we hold a reference of the created ServiceClient object (or the Registry Manager)?
and what is the impact in case
when we open-close the connection?
when we leave open the conection?
Is the use-case of the ServiceClient to send messages to devices?
Yes. You need use ServiceClient to send C2D messages.
ServiceClient supports only amqp messages. Documentation for Azure
Devices namespace says "Transport types supported by ServiceClient -
Amqp and Amqp over WebSocket only". In code the TransportType exposes
only Amqp. Would it be changed in the future?
For future plans, you can reference this guide ask a question.
If the ServiceClient is been used for C2D messages, why in this
answer, is written that "For ServiceClient, you need Azure IoT Hub
connection string, not device connection string"?
Device connection string: Connection string based on primary key used in API calls which allows device to communicate with Iot Hub. It allows you to receive C2D messages, not send C2D messages. IoT Hub exposes its functionality to various actors, like per-device and service.
What is the performance's impact and resources' utilization, if we
hold a reference of the created ServiceClient object (or the Registry
Manager)?
You can check IoT Hub throttling and you and IoT Hub quotas and throttling for more detail.
When using DeviceClient I can send messages using SendEvent and files using SendBlob. But I did not find a way to receive acknowledgement that messages/files have been received by Azure IoT Hub?
The only way I found to solve this is using serviceClient.GetFileNotificationReceiver().
Am I missing something or is this the only way?
Also it seems I need SharedAccessKeyName to use ServiceClient. But this is not present in e.g. tokens created by DeviceExplorer (which I use for DeviceClient). Any advice is appreciated.
For Java and C sdks there are IotHubEventCallback and IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK but for C# there is no such interface implemented.
So, for C#, a message will be sent successfully if DeviceClient.SendEventAsync() without throwing any exception, otherwise it fails.
Or you can utilize Event Hub-compatible endpoint to monitor the status of operations on your IoT hub, D2C message, file upload...
For ServiceClient, you need Azure IoT Hub connection string, not device connection string. You can find it in Configuration of Device Explorer: