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 for AMQPNetLite:
- Declare the global variables:
string IoThubURI = "IoTHubCookBook.azure-devices.net";int port = 5671;
- We will create a SendEvent method which accepts the deviceId parameter.
- Initialize the variables required for AMQP connection with IoT Hub:
string to = Fx.Format("/devices/{0}/messages/events", deviceId);string entity = "/messages/events";string audience = Fx.Format("{0}/devices/{1}", ...