Build a prototype

Connect to Azure

The Internet of Things is built on cloud computing. Communicating with the cloud and deriving insight from data is an essential part of any IoT project. Now that you've built a Windows 10 IoT Core application, let's connect it to Azure.

We'll be using Azure IoT Hub to connect our device to the cloud. Here’s what you need to know:

  • Azure IoT Hub is a cloud service that offers device-to-cloud and cloud-to-device messaging.
  • Messaging is the primary method devices use to communicate with the cloud and each other. The message can be a command from the cloud to a device ("Take a picture"), data from a device to the cloud ("Here's the image data you requested"), and a host of other possibilities.
  • Security is important. Our goal is for each message to be received and sent with no tampering in the middle; the data can contain information that must be encrypted.

To provision your prototype, you can use the Windows 10 IoT Core Dashboard, available on the downloads page if you haven't yet downloaded it during the prototyping process.

The Dashboard produces an image of the OS and securely connects your device to Azure. This is done by associating the physical device with the device ID in the Azure IoT Hub and imprinting the device-specific shared access key to the device’s TPM.

For devices that don’t have a TPM chip, the tool can install a software-emulated TPM. This does not provide security but allows you to develop your app using a prototyping device (such as Raspberry Pi 2 or 3) and have security “light up” on a device with the hardware TPM without having to change the app.

To connect your device to Azure, click on the Connect to Azure tab in the Dashboard:


Connect device to cloud

You will be asked to log in to your Azure account. Pick the desired instance of Azure IoT Hub and associate your physical device with it. If you don’t have any IoT Hub instances in your Azure subscription, the tool will let you create a free instance.

Once you have selected the IoT Hub and the device ID to associate your device with, you can imprint the shared access key of that device on your Trusted Platform Module (TPM):

Provision your device to connect to Azure

Now that you've provisioned your device, you're ready to connect your app to Azure. For this example, use the app you wrote in the previous section 

Within your app, follow the instructions from the Connected Services tool to connect your project to Azure IoT Hub. The tool will generate two functions, SendDeviceToCloudMessageAsync and ReceiveCloudToDeviceMessageAsync that you can invoke anywhere in your app. You can modify these functions as you see fit. Use the first function to send messages to Azure, and the second to act on data the cloud sends to the device.

After successfully connecting your app to Azure using the IoT Dashboard, we'll challenge you to use Visual Studio to connect your app to the cloud. Follow the instructions in our Windows 10 IoT Core blog.

Microsoft offers libraries and tools that allow you to build your connected IoT applications that connect to Azure IoT Hub. It's easy to get started and scales up as your solution does. You can find the code for Azure's Device Client Management as well as Azure's Device Provisioning Service in GitHub. 


Questions/Suggestions


Ask the community or give us feedback (Windows 10 required for this tool)


Edit this page on GitHub