Using Beam to connect to Azure IoT Hub

Soracom Beam allows you to send data from a device to specific cloud services over cellular. With Beam, you can encrypt data being sent from the device by changing its protocol, and also manage cloud endpoints without having to update any code on the device itself.

By using Beam, you can:

In this guide, we'll cover how to use Beam in order to send MQTT data to Azure IoT Hub. Let's get started.

Prerequisites


Configure Azure IoT Hub

1. Create an IoT Hub


2. Create an IoT Device


3. Get a Shared Access Policy

Although IoT Hub generated device-specific authentication keys in the last step, we will use a Shared Access Policy which will let multiple devices authenticate using the same authentication key.

We are now done setting up Azure IoT Hub. Let's take a second to quickly review the details:


Configure Soracom Beam

Now we can head over to the Soracom User Console and set up the connection between Beam and IoT Hub.

4. Add a Beam Configuration

Let's open the group which contains our Soracom Air SIM in order to set up Beam. You can either click the name of the group from the SIM Management page, or from the Groups page.


Test the connection

5. Monitor the Azure IoT broker

We will use Azure IoT Extension for Azure CLI to monitor the IoT Hub for published messages.

6. Send a test message

Now that event monitoring is running, it's time to publish a message from our device to Beam. We are using a Raspberry Pi for our test, so we can use the Eclipse Mosquitto MQTT client to publish a message.

Once the above message is published, you should see it appear in the event monitor:

az iot hub monitor-events -n soracom-beam -d my-air-device
>Starting event monitor, filtering on device: my-air-device, use ctrl-c to stop...
>{
>    "event": {
>        "origin": "my-air-device",
>        "payload": "Hello from Soracom Beam!"
>    }
>}

Conclusion

Congratulations, you've successfully published an MQTT message to an Azure IoT Hub through Soracom Beam. Notice how we didn't need to store the IoT Hub endpoint or the credentials on the device. Since the connection between the device and Soracom's cloud is encrypted over cellular, we just had to configure the hop between Soracom and Azure. This means that devices can be deployed at scale without having to worry about managing credentials, endpoints, or compute resources needed to manage cryptographic handshakes.