Use Cloud Explorer for Visual Studio to send and receive messages between your device and IoT Hub
Cloud Explorer is a useful Visual Studio extension that enables you to view your Azure resources, inspect their properties and perform key developer actions from within Visual Studio. This article focuses on how to use Cloud Explorer to send and receive messages between your device and your hub.
Some of the features mentioned in this article, like cloud-to-device messaging, device twins, and device management, are only available in the standard tier of IoT Hub. For more information about the basic and standard IoT Hub tiers, see How to choose the right IoT Hub tier.
What you learn
In this article, you learn how to use Cloud Explorer for Visual Studio to monitor device-to-cloud messages and to send cloud-to-device messages. Device-to-cloud messages could be sensor data that your device collects and then sends to your IoT Hub. Cloud-to-device messages could be commands that your IoT Hub sends to your device. For example, blink an LED that is connected to your device.
What you do
In this article, you do the following tasks:
Use Cloud Explorer for Visual Studio to monitor device-to-cloud messages.
Use Cloud Explorer for Visual Studio to send cloud-to-device messages.
What you need
You need the following prerequisites:
An active Azure subscription.
An Azure IoT Hub under your subscription.
Microsoft Visual Studio 2017 Update 9 or later. This article uses Visual Studio 2019.
The Cloud Explorer component from Visual Studio Installer, which is selected by default with Azure Workload.
Update Cloud Explorer to latest version
The Cloud Explorer component from Visual Studio Installer for Visual Studio 2017 only supports monitoring device-to-cloud and cloud-to-device messages. To use Visual Studio 2017, download and install the latest Cloud Explorer.
Sign in to access your hub
To access your hub, follow these steps:
In Visual Studio, select View > Cloud Explorer to open Cloud Explorer.
Select the Account Management icon to show your subscriptions.
If you are signed in to Azure, your accounts appear. To sign into Azure for the first time, choose Add an account.
Select the Azure subscriptions you want to use and choose Apply.
Expand your subscription, then expand IoT Hubs. Under each hub, you can see your devices for that hub.
Monitor device-to-cloud messages
To monitor messages that are sent from your device to your IoT Hub, follow these steps:
Right-click your IoT Hub or device and select Start Monitoring D2C Message.
The monitored messages appear under Output.
To stop monitoring, right-click on any IoT Hub or device and select Stop Monitoring D2C Message.
Send cloud-to-device messages
To send a message from your IoT Hub to your device, follow these steps:
Right-click your device and select Send C2D Message.
Enter the message in input box.
Results appear under Output.
You’ve learned how to monitor device-to-cloud messages and send cloud-to-device messages between your IoT device and Azure IoT Hub.
To continue to get started with Azure IoT Hub and to explore all extended IoT scenarios, see the following: