Using AMQP library to communicate with IoT Hub
AMQP is a binary transfer protocol made for server-to-server communication, but nowadays, it is widely used in IoT solutions. Azure IoT SDK supports the AMQP communication protocol.
However, in this recipe, we will be using the Amqp.Net Lite
library that provides an AMQP protocol stack written in C#. This can be used across multiple .NET-based platforms such as console or UWP applications.
Getting ready
IoT Hub expects secure connectivity with AMQP by making a connection over port 5671
when data is ingested from the device to the IoT Hub.
In this recipe, we will make a sender link and a receiver link. The sender will be used for telemetry data to the cloud and the receiver will be designed to accept the commands and process them.
How to do it...
We will use the AMQP library to implement using a AMQP protocol directly with IoT Hub:
- Create a C# console application and add a class
amqpClient
. - Open the
Add new
NuGet packages and search forAMQPNetLite
:

A...