Skip to content

Azure-Samples/IoTMQTTSample

Repository files navigation

page_type languages products name description
sample
c
python
azure-iot-hub
IoT MQTT Samples
Using MQTT with Azure IoTHub without SDK

Using MQTT with Azure IoT Hub without an SDK

This set of samples will demonstrate how to connect and send messages to an Azure IoT Hub without using the Azure IoT SDKs.

Read the Communicate with your IoT Hub using the MQTT protocol for detailed instructions on connecting your device to IoT Hub using MQTT without an SDK.

Why use an Azure IoT Device SDK?

Azure provides a set of SDKs across multiple languages for connecting device to IoT Hub and DPS. The advantages of using an Azure IoT Device SDK over building a custom connection layer are outlined below:

Custom connection layer Azure IoT Device SDKs
Support Need to support and document your solution Access to Microsoft support (GitHub, Microsoft Q&A, Microsoft technical documentation, Customer Support teams)
New Features Need to manually add new Azure features Can immediately take advantage of new features added
Investment Invest hundreds of hours of embedded development to design, build, test, and maintain a custom version Can take advantage of free, open-source tools. The only cost associated with the SDKs is the learning curve.

For more information, refer to the Overview of Azure IoT Device SDKs.

Samples in this repo

This repository contains the following samples:

Root certificates

Note Azure IoT services are moving to a new CA root, see here for details.

This repository provides the file IoTHubRootCA.cert.pem which contains the following root certificates:

Certificate Description
Baltimore CyberTrust Root NOT recommended since IoT Hub migration out of Baltimore will start in Feb 2023
DigiCert Global Root G2 Future Root CA to become active in Feb 2023
Microsoft RSA Root Certificate Authority 2017 Additional Root recommended to prevent disruption from future changes

General Prerequisites

To be able to run these samples the following general prerequisites are needed:

  1. Clone this repository (Install Git)
  2. Change into the cloned directory:
    cd IoTMQTTSample
  1. Install the Azure CLI

  2. Provision an IoT Hub in your Azure subscription

  3. Register a device within your IoT Hub

  4. Generate a SAS token for the device using the Azure CLI

    Note By default the SAS Token is valid for 60 minutes. Use the --du parameter to increase if needed.

Additional prerequisites may be required by each individual sample.

Contributing

For details on contributing to this repository, see the contributing guide.

Reporting Security Vulnerabilities

If you believe you have found a security vulnerability in any Microsoft-owned repository that meets Microsoft's definition of a security vulnerability, please report it to the Microsoft Security Response Center.