How to test Messages arriving in Azure IoTHub
Asked Answered
T

4

19

I have an event generator connected and publishing messages into an IoT hub. How do I check what message have arrived? I'd be interested in different ways to determine (programmatically, dashboard, etc)

Taboo answered 13/2, 2016 at 14:49 Comment(0)
I
19

There is a cross-platform Azure IoT Toolkit extension for Visual Studio Code to make you able to monitor the messages sent to Azure IoT Hub.

device-explorer

You could check out the Wiki Page to see the full features and tutorials.

Monitor-IoT-Hub-D2C-Message

Involucre answered 26/10, 2016 at 0:21 Comment(0)
U
12

If you want to simply test the messages, you can download the Device Explorer sample app (open source on GitHub), configure it with your connection string and monitor the messages.

enter image description here

Uproar answered 13/2, 2016 at 15:33 Comment(3)
Does this evict the message from IoT Hub?Taboo
Messages are deleted after the defined retention periodUproar
Device Explorer has been discontinued, source code is removed from the repo. It has been replaced by the Azure IoT Explorer, repo is here: github.com/Azure/azure-iot-explorerIllfated
V
11

Just adding two more options for future reference:

Azure CLI

The IoT extension readme describes several ways to install the extension. The simplest way is to run az extension add --name azure-iot

At a PowerShell prompt type

  • az login

The az login command will open a new web browser window and ask your to log into your Azure Subscription account.

Edit: Another option, you could also login in the command line:

az login -u <username> -p <password> 
  • Next we need to generate a SAS token.

We can do this by running this command in the Azure CLI window:

az iot hub generate-sas-token --duration -n

Now we have our SAS Token, we can start monitoring the hub messages by running the following command:

az iot hub monitor-events --hub-name

for more details please read: https://github.com/AzureIoTGBB/How-To-Monitor-Azure-IoT-Hub-with-Azure-CLI-2.0

Azure Function

  • Create a Function App by clicking the below in the Azure Portal “Create New” blade. This is the “container” which holds your functions.
  • Once the Function is created, navigate to the “Create new function from template page”: Select IoT Hub (Event Hub) and Javascript or C# as the language Conveniently, Azure Functions will create the connection with IoT Hub for you after selecting this template,
  • Next you just have to click on the "new" button and select the proper IoT Hub instance:
  • Click "Create" and the Function just created will be triggered by the IoT Hub events
  • The function is created with boilerplate code console logging the messages
Vermicide answered 13/2, 2019 at 17:2 Comment(3)
I had to add an extension to the Azure CLI in order for the listed commands to work az extension add --name azure-cli-iot-extPacifistic
You can also login in command line: az login -u <username> -p <password>Puett
Please, update your CLI command. The actual version of it is: az extension add --name azure-iotBuchner
B
5

The easiest way to just see the latest messages coming in is maybe using the cloud shell in the Azure portal.

From the Portal Home page, open it by clicking the "Shell" icon in the upper right corner.

Then do

az extension add --name azure-iot
az iot hub monitor-events --hub-name <youriothubname>

With this, the incoming events start to appear in the console.

Bergquist answered 21/12, 2020 at 17:9 Comment(1)
Requires extra azure storage costs to set up the cloud shell. This shouldn't be difficult to setup yourself locally but currently, not supported for M1 macs I believe.Hallow

© 2022 - 2024 — McMap. All rights reserved.