Use Cloud Explorer for Visual Studio to send and receive messages between your device and IoT Hub

End-to-end diagram

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.

Note

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:

  1. In Visual Studio, select View > Cloud Explorer to open Cloud Explorer.

  2. Select the Account Management icon to show your subscriptions.

    Account Management icon

  3. If you are signed in to Azure, your accounts appear. To sign into Azure for the first time, choose Add an account.

  4. Select the Azure subscriptions you want to use and choose Apply.

  5. Expand your subscription, then expand IoT Hubs. Under each hub, you can see your devices for that hub.

    Device List

Monitor device-to-cloud messages

To monitor messages that are sent from your device to your IoT Hub, follow these steps:

  1. Right-click your IoT Hub or device and select Start Monitoring D2C Message.

    Start Monitoring D2C Message

  2. The monitored messages appear under Output.

    Monitoring D2C Message Result

  3. 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:

  1. Right-click your device and select Send C2D Message.

  2. Enter the message in input box.

    Send C2D Message

    Results appear under Output.

    Send C2D Message Result

Next steps

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: