iothub-explorer will be retired on November 31st, 2018 and has been replaced by the Azure CLI IoT Extension.
A CLI tool to manage device identities in your IoT hub registry, send and receive messages and files from your devices, and monitor your IoT hub operations.
iothub-explorer also lets you simulate a device connected to your IoT hub.
Note: This tool requires Node.js version 4.x or higher for all features to work.
To install the latest version of the iothub-explorer tool, run the following command in your command-line environment:
npm install -g iothub-explorer
You can use the following command to get additional help about all the iothub-explorer commands:
$ iothub-explorer helpUsage: iothub-explorer [options] <command> [command-options] [command-args]Commands:login start a session on your IoT hublogout terminate the current session on your IoT hublist list the device identities currently in your IoT hub device registrycreate <device-id|device-json> create a device identity in your IoT hub device registrydelete <device-id> delete a device identity from your IoT hub device registryget <device-id> get a device identity from your IoT hub device registryimport-devices import device identities in bulk: local file -> Azure blob storage -> IoT hubexport-devices export device identities in bulk: IoT hub -> Azure blob storage -> local filesend <device-id> <message> send a message to the devicemonitor-feedback monitor feedback sent by devices to acknowledge cloud-to-device messagesmonitor-events [device-id] listen to events coming from devicesmonitor-uploads monitor the file upload notifications endpointmonitor-ops listen to the operations monitoring endpoint of your IoT hub instancesas-token <device-id> generate a SAS Token
Each iothub-explorer command has its own help that can be viewed by passing
help the command name:
$ iothub-explorer help createUsage: iothub-explorer create [options] [device-id|device-json]Create a device identity in your IoT hub device registry, either using the specified device id or JSON description.Options:-h, --help output usage information-a, --auto create a device with an auto-generated device id-cs, --connection-string show the connection string
Working with the device identity registry
Supply your IoT hub connection string once using the login command. This means you do not need to supply the connection string for subsequent commands for the duration of the session (defaults to one hour):
$ iothub-explorer login "HostName=<my-hub>.azure-devices.net;SharedAccessKeyName=<my-policy>;SharedAccessKey=<my-policy-key>"Session started, expires Fri Jan 15 2016 17:00:00 GMT-0800
Note: See Set up IoT Hub for information about how to retrieve your IoT hub connection string.
To retrieve information about an already-registered device from the device identity registry in your IoT hub, including the device connection string, use the following command:
$ iothub-explorer get known-device --connection-string-deviceId: known-device...-connectionString: HostName=<my-hub>.azure-devices.net;DeviceId=known-device;SharedAccessKey=<known-device-key>
To register a new device and get its connection string from the device identity registry in your IoT hub, use the following command:
$ iothub-explorer create new-device --connection-stringCreated device new-device-deviceId: new-device...-connectionString: HostName=<my-hub>.azure-devices.net;DeviceId=new-device;SharedAccessKey=<new-device-key>
To delete a device from the device identity registry in your IoT hub, use the following command:
$ iothub-explorer delete existing-device
Working with devices
Use the following command to monitor the device-to-cloud messages from a device:
$ iothub-explorer monitor-events myFirstDevice --login "HostName=<my-hub>.azure-devices.net;SharedAccessKeyName=<my-policy>;SharedAccessKey=<my-policy-key>"Monitoring events from device myFirstDeviceListening on endpoint iothub-ehub-<my-endpoint>/ConsumerGroups/$Default/Partitions/0 start time: 1453821103646Listening on endpoint iothub-ehub-<my-endpoint>/ConsumerGroups/$Default/Partitions/1 start time: 1453821103646Event received:
Note: The monitor-events command requires you to provide the IoT Hub connection string even if you have created a session using the login command.
Use the following commands to send a cloud-to-device command and then wait for the device to respond with an acknowledgment:
$ iothub-explorer send myFirstDevice MyMessage --ack=fullMessage sent$ iothub-explorer monitor-feedback myFirstDeviceWaiting