Share via

End-to-end .NET IoT and Azure IoT Hub example

This sample console application provides an example that combines learnings from the following two Microsoft Learn modules:

Important

It is strongly recommended that you complete the two list Microsoft Learn modules before using this sample.

Running the sample

  1. Provision an Azure IoT Hub resource and device as described in Exercise - Create an Azure IoT Hub, and a device ID, using the Microsoft Azure portal.
  2. In Program.cs, replace YOUR DEVICE CONNECTION STRING HERE with your device connection string from the previous step.
  3. Construct a device as described in Exercise: Construct IoT hardware.
  4. Deploy the app to your device as described in Exercise: Deploy app to Raspberry Pi.
  5. Run the app as described in Exercise: Test the app

You will be able to interact with the device in the Azure portal using direct methods and device twins. The cheesecaveoperator back-end app is optional.

A screenshot of the Azure portal showing a direct method being invoked

A screenshot of the Azure portal showing a device twin with temperature and humidity data