Getting Started with IoT with AWS and Microsoft Azure

Companies have been using devices and sensors to measure and quantify data for a while now. By 2020, Gartner predicts that more than 65% of enterprises will adopt Internet of Things (IoT) products, compared to just 30% today. The low cost of devices and the wide availability of the internet gives companies even more reasons to explore their potential. To do so, companies need solid tools to manage infrastructure and devices on an increasingly large scale.

The cloud offers not only the high scalability and availability to support IoT initiatives but also tools for delivering insight through big data and machine learning. The leading cloud platforms have created services to help companies and developers focus on building applications and delivering features without worrying about the underlying infrastructure. In this post, we’ll explore the IoT services offered by Amazon Web Services and Microsoft Azure. We’ll begin with a brief introduction and then walk you through the process of getting started with each platform.

What is Internet of Things (IoT)?

For now, you can think of the IoT as a system that uses the infrastructure of the internet to establish a connection to and between our electronic devices.

IoT Architecture and Cloud Services in the IoT Ecosystem

In the cloud, the major vendors—Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform—have worked in similar ways to implement the general process of IoT into their platforms.

This includes device registry to connect your device with the cloud, device management on the cloud, and messaging via some popular protocols that use a standard publisher-subscriber or pub/sub model to ensure that your devices will connect using the appropriate protocol and publish data in the form of topics. Applications will subscribe to that topic and be notified of any data published related to the topic. Then, they will execute a real-time data analytics process with the data sent by your device sensor and monitor the IoT device with different status information from data virtualization tools in the cloud.

Let’s look at how these processes are implemented by AWS and Azure.

AWS IoT: How it Works

AWS IoT allows you to connect devices to AWS services and other devices, secure data and interactions, process and act upon device data, and enable applications to interact with devices even when they are offline.

The main process of AWS IoT is making sure your device is recognized or connected by the IoT Hub, which is referred to as the ‘device connected or registry process.’

To do this, you’ll need to first install Amazon Device SDK on your device. The AWS IoT Device SDK enables your devices to connect, authenticate, and exchange messages with AWS IoT using MQTT, HTTP, or WebSocket protocols. SDKs are available in C, Node.js, Java, Python, Arduino, and mobile SDKs are available for Android and iOS. The registry is used to establish an identity for your devices and can keep data about your devices, store device attributes, and keep track of devices. Refer to the Introduction to AWS IoT Lab to learn more.

Another way is to directly start with AWS IoT Starter Kits. These physical kits are designed to help accelerate the cloud-powered prototype development of connected devices and connect securely to AWS IoT. The kits include microcontroller development boards, sensors and actuators, the AWS IoT Device SDK, and a simple getting started guide to help you find the best fit for your products. Refer to the  Getting Started with AWS IoT section on the AWS site to learn more. Visit the APN partner portal to learn more about partners who provide AWS IoT Starter Kits.

During the connection process, AWS provides authentication and authorization with your own certificate or the certificate provided by AWS, which is built into the AWS IoT service to securely connect your devices to the platform. This means that AWS IoT is able to identify which devices are connected and verify that another device is not impersonating yours. It also allows devices to verify that they are connecting to AWS IoT and not some other entity impersonating the platform.

AWS provides authentication and authorization with your own certificate.

Identify “things” in AWS.
After registering your device, you should have a mechanism to exchange data messages between your device and AWS IoT, which is known as Device Gateway. It supports standard protocols such as MQTT, HTTP, and WebSockets.
Devices that are connected to Amazon’s IoT Service are listed in the registry. They are managed by the AWS IoT Rules Engine, which provides message processing, transformation, and integration with other AWS services. It uses an SQL-based language to select data from message payloads, process the data, and send the data to other Amazon services such as S3, Lambda, DynamoDB, and others.

Use the AWS IoT Rules Engine to define actions.
To persist the last reported state and desired future state of each device even when the device is offline, AWS implemented Device Shadows. Device Shadows are virtual representations of physical things or devices. You can retrieve the last reported state of a device or set a desired future state through the REST API or use the rules engine.

AWS IoT Architecture
Finally, monitoring is an important part of maintaining the reliability, availability, and performance of AWS IoT. AWS will collect monitoring data from all parts of your AWS solution so that we can more easily debug a multi-point failure if one occurs. AWS IoT is integrated with CloudTrail, a service that captures all of the AWS IoT API calls and delivers the log files to a specified Amazon S3 bucket. CloudTrail captures API calls from the AWS IoT console or from your code to the AWS IoT APIs. Using the information collected by CloudTrail, we can determine the request that was made to AWS IoT, the source IP address from which the request was made, who made the request, when it was made, and so on.

AWS IoT Monitoring
If you haven’t had a chance to work with AWS IoT, I recommend taking the Introduction to the AWS IoT course on Cloud Academy to learn all the basics you need to know to get started.

Azure IoT: How it Works

The Azure IoT service offers a broad range of capabilities. These enterprise-grade services can be used to:

  • Ingest data (collect data from devices and ingress of data at scale to the cloud)
  • Manage devices
  • Analyze data streams in motion
  • Store and query large data sets
  • Visualize both real-time and historical data
  • Integrate with back-office systems

This schema shows how it works:


Azure IoT architecture

Related Services in the IoT Suite Ecosystem on Microsoft Azure

The Microsoft Azure IoT Suite is an enterprise-grade solution that enables you to get started quickly through a set of extensible, preconfigured solutions. These solutions address common IoT scenarios such as remote monitoring, predictive maintenance, and connected factory. The preconfigured solutions are complete, working, end-to-end solutions that include the following services:

  • Azure IoT Hub provides device-to-cloud and cloud-to-device messaging capabilities and acts as the gateway to the cloud and the other key IoT Suite services. With Azure IoT Hub, you can manage your devices, receive messages from your devices at scale, and send commands to your devices.
  • Azure Stream Analytics provides in-motion data analysis for the IoT Suite to process incoming telemetry, perform aggregation, detect events, and to process messages from your devices and deliver them to other services.
  • Azure Storage and Azure Cosmos DB are used to providing data storage capabilities. Usually, we use blob storage to store telemetry and to make it available for analysis. Cosmos DB is used to store device metadata and enable the device management capabilities of the solutions.
  • Azure Web Apps and Microsoft Power BI provide data visualization capabilities to quickly build your own interactive dashboards that use IoT Suite data.

Azure IoT in Action

Now, we’re going to create an Azure IoT Hub.

On the left side of the Azure portal in the search text box, type IoT Hub and press Enter to create an IoT Hub. Fill out the basic information required in the IoT Hub blade. The number of IoT Hub units entered here determines your daily message quota, so we can calculate your daily message requirements and purchase the appropriate number of units. Device-to-cloud partitions is the number of partitions for device-to-cloud messages. The pricing and scale tier will be determined by the number of messages across all devices. For more insights into Azure IoT Hub, see the Introduction to IoT Hub here.


Creating your Azure IoT Hub.

Device Register

Similar to AWS, we should connect devices to Azure IoT using the Azure IoT SDK. There are three categories of software development kits (SDKs) for working with IoT Hub:

  • Device SDKs allow you to build apps that run on your IoT devices. These apps send telemetry to your IoT hub and optionally receive messages from your IoT hub.
  • Service SDKs allow you to manage your IoT hub and optionally send messages to your IoT devices.
  • Azure IoT Edge allows you to build gateways for devices that don’t use one of the supported protocols. Gateways can also process messages on the edge.

SDKs are provided to support multiple programming languages such as C, node.js, Java, Net, and Python.

Microsoft Azure also provides its own IoT Developer Kit to help jump start your IoT project. It is a prototyping board with lots of sensors, buttons, OLED displays, Wifi, and more, all built in. To find the right IoT device for your project, please refer to Find your IoT device.

I’d like to recommend two useful tools to help you manage your IoT devices on the Azure cloud. The IoT Hub Explorer is a CLI tool that allows you to manage device identities in IoT Hub Registry, send and receive messages and files from your devices, and monitor your IoT Hub operations. It also allows you to simulate a device connected to IoT Hub. Device Explorer runs on a local machine and connects to IoT Hub to manage devices.

Data Analytics Job

Most data that comes into an IoT Hub will need some sort of processing or analytics executed to discern meaningful data.

Microsoft implemented the Stream Analytics Job, which takes input, runs a query against that data, and then sends the results to some form of output. While a Stream Analytics Job can handle many different input sources, here we’ll be using our IoT Hub’s messages as our source. There can also be many outputs, from a storage location to a database or additional functions.

Azure IoT Hub working with Stream Analytics

Data Virtualization – Power BI (Data Analytics Job)

Microsoft provides a real-time data virtualization tool, known as Power BI. Power BI it is a suite of business analytics tools that deliver insights throughout your organization. With Power BI, you can connect to hundreds of data sources, simplify data prep, and drive ad hoc analysis. You’ll be able to produce beautiful reports, then publish them for your organization to consume on the web and across mobile devices. Everyone can create personalized dashboards with a unique, 360-degree view of their business.

They are made to scale across the enterprise, with governance and security built-in.

Here is an example of a Power BI report:


Data Virtualization with Power BI

Azure Device Management and Lifecycle

Azure IoT Hub provides features that, along with its extensibility model, enable device and back-end developers to build robust device management solutions. To be successful, a solution must accommodate devices that range from constrained sensors and single-purpose microcontrollers to powerful gateways that route communications for groups of devices. There are five device management stages within the device lifecycle that are common to all enterprise IoT projects:

  • Plan: Operators can create a device metadata scheme that enables them to easily and accurately query for and target a group of devices for bulk management operations.
  • Provision: Securely provision new devices to IoT Hub and enable operators to immediately discover device capabilities.
  • Configure: Facilitate bulk configuration changes and firmware updates to devices while maintaining both health and security.
  • Monitor: Monitor overall device collection health, the status of ongoing operations, and alert operators to issues that might require their attention.
  • Retire: Replace or decommission devices after a failure, upgrade cycle, or at the end of the service lifetime. Use the device twin to maintain device info if the physical device is being replaced or archived if being retired. Use the IoT Hub identity registry for securely revoking device identities and credentials.

To learn more about IoT, I recommend to these great courses on Cloud Academy by Ben Lambert: Building an Information Display Solution with Azure IoT Hub and Developing for The Raspberry Pi and Azure IoT Hub.

I hope this article has helped you understand how AWS and Azure IoT work and that it will help you choose the best platform for your IoT requirements. In my next post, I’ll be writing about Lambda architecture, data processing on Azure, and machine learning for predictive purposes.

Cloud Academy Team

Recent Posts

Get 50% off with the Cloud Academy’s Flash Sale!

It's Flash Sale time! Get 50% off your first year with Cloud Academy: all access to AWS, Azure, and Cloud…

1 month ago

New AWS Certified Data Engineer – Associate (DEA-C01) exam goes live on March 12th, 2024!

In this blog post, we're going to answer some questions you might have about the new AWS Certified Data Engineer…

2 months ago

Navigating the Vocabulary of Generative AI Series (3 of 3)

This is my 3rd and final post of this series ‘Navigating the Vocabulary of Gen AI’. If you would like…

4 months ago