Azure IoT Edge OPC Publisher message encoding - azure-iot-hub

I want to send telemetry data from Azure iot edge device to IoTHub through OPC publisher module.
OPC publisher can be configured to encode the message either Json ("--me=Json") or Uadp ("--me=Uadp") before sending.
OPC Publisher parameters
https://github.com/Azure/Industrial-IoT/blob/main/docs/modules/publisher-commandline.md
So I configured my edge device to send the message in uadp message encoding format as its compact and compressed , However When I monitor the message received to IoTHub, its unreadable.
Message monitoring in IoTHub
Any one can help how we can decode the uadp message to readable format in IoTHub so I can process it in Azure stream analytics

Azure IoTHub messages will be encoded as per the encoding type set and saved. To decode the messages you use the "Azure Function" This can be triggered directly from the IoT-Hub. Please see the discussion on similar ask and see if it helps: https://learn.microsoft.com/en-us/answers/questions/230228/iot-hub-message-routing-received-json-message-body.html
To decode the message use the "Function App". This can be triggered directly from the IoT-Hub.
Add a consumer under "built in endpoints" -> "Consumer groups".
Under IoT-Hub message routing create a new route as "Endpoint: events" and "Data-source: Device telemetry messages".
When you create a new function use template "IoT Hub (event hub).
"event-hub-connection" was autmatically filled in. Under "event Hub-consumer..." fill in the consumer-group you created.
Then create all the rest to decode the message and write it to the place you want.

Related

Writing data to Azure Iot hub device

I am currently doing a POC where I would like to know if this is possible using Azure Services. I get certain data from Iot hub in my Event hub which triggers a logic app, and based on the message received from Event hub, My logic app would send a message to IoT Edge device. i would like to know if it is possible to send message to IoT hub device from logic app? and if yes how can we do that?
I am more looking Yes or No answer to my question and If I get the services to be used to achieve this.. It will be great
Yes, this is possible. Logic Apps have an Event Hub connector that you can use to start your app when a message comes in.
To send a message to your Azure IoT Edge device from a logic app, you could use the REST API. It allows you to send a direct method to a specific module on the device. The device needs to be online for it to receive the message, otherwise, the REST call will result in an error.
The challenge is that you will need to get a valid security token to complete this call, you could certainly add this to your app as a variable, but you shouldn't. You also run the risk of exposing this secret value in your run history. You could write an Azure Function to generate this security token and retrieve it with the Logic App. At this point you're writing code anyway, the problem you're trying to solve with a Logic App would be a better fit for an Azure Function.

Azure IoT Hub monitoring usage and history

I recently started a project with Azure IoT Edge with the IoT Hub Free Tier so I'm a total beginner. I set up a device sensor, a module and I am sucessfully sending data to my module and IoT Hub. I can
monitor the messages sent from the sensor with Azure IoT Hub expension from Visual Studio Code.
I can see the messages I'm sending but I am having an issue with the number of messages being sent.
I use Azure portal metrics to monitor the number of messages sent and very often Azure would show me different numbers as I refresh. For example "1000" messages and after a refresh "800" messages etc...
Another issue I'm having is also that when using the Metrics functionality, it shows me that some messages are being sent during a time where my sensors weren't sending any messages.
Is there a way to get a detailled report with a history on the messages that the Hub receives?
Any help or advice would be highly appreciated! Thank you
As far as I know there is no "nice and simple" report which will show you what you need. However, if you want to get historical events which IoT hub processed it can be done. Note, though, that history is limited and can be no longer than 7 days. Current retention period can be seen on the azure portal in "Built-in endpoints" section - there is a "Retain for" setting with the value from 1 day (default) to 7 days.
If events are within this range, you can use Powershell command "az iot hub monitor-events" with the --enqueued-time parameter to "look back" in history. The time is specified in milliseconds since unix epoch. Example command:
az iot hub monitor-events --hub-name 'your_iot_hub_name' --device-id  'your_registered_device_id' --properties all --enqueued-time 1593734400000

USB interrupt endpoint is unidirectional?

On reading about usb protocol in
http://www.beyondlogic.org/usbnutshell/usb4.shtml
It is said that interrupt endpoint is unidirectional and periodic.
Yet, I see in the description for IN interrupt endpoint, that host initiate the IN token and then data packet is send from device to host.
"If an interrupt has been queued by the device, the function will send
a data packet containing data relevant to the interrupt when it
receives the IN Token."
So, If the data packet is sent on this IN endpoint from device to host, doesn't it mean that the same endpoint is used both the transmit and receive ?
I believe the terminology "unidirectional" is meant for only data and not for token and handshake packets. So "IN" endpoint is for reading data and "OUT" endpoint is for writing data. That's why its called unidirectional.
But control endpoint is bidirectional because you can read or write data using the control endpoint. Check the standard USB commands like "Get Descriptor" and "Set Descriptor".

Iot Hub - default event hub receive same message twice

I'm having APi Service that handle some information from my device. After that i use default Iot-HUB SDK that allows me to send data into Iot-Hub. In my event hub I usually get data that I send more than once. Is there any options to see what it happens ? Maybe some extra settings that to retransmission or something that send messages more than once from my web api service ?
I had the same problem with my code. I was sending messages to an iothub using an Azure function. I had the message sending time trigger as a variable. When sending messages in shorter frequencies (i.e. messages that are sent each second) some of these messages are duplicated.
By changing the message protocol it solved. Given below is the corrected code,
DeviceClient deviceClient = DeviceClient.CreateFromConnectionString(connectionString, TransportType.Http1);

How to view Azure storage account queue

I have a queue in my Azure storage account queue. I want a tool to see what is inside that queue.
I have tried 'CloudBerry Explorer for Azure Blob Storage', but that does not let me see the content of the queue.
And I tried 'Azure Storage Explorer', I can only see top 32 messages of the queue.
Can I see all the message in the queue?
And is there a tool allow me to change the order of message in the queue?
Azure Queue storage does not guarantee message ordering and therefore does not also provide a way to reorder messages.
There are two ways to see the contents of existing messages: Get Messages API and Peek Messages API. Both allow retrieving up to 32 messages at a time, so there is no way to view more than 32 messages without making the first 32 invisible (dequeue) first with Get Messages API.