platform | device | language |
---|---|---|
debian, Linux, raspbian, Ubuntu, windows |
any |
Python |
About this document
This document describes how to run the iothub_client_sample_amqp.py Python sample application. This multi-step process includes:
- Configuring Azure IoT Hub
- Registering your IoT device
- Build and deploy Azure IoT SDK on device
You should have the following items ready before beginning the process:
- Computer with Git client installed and access to the azure-iot-sdks GitHub public repository.
- Prepare your development environment
- Setup your IoT hub
- Provision your device and get its credentials
- Make sure desktop is ready as per instructions given on Prepare your development environment.
-
Navigate to the folder python/device/samples in your local copy of the repository.
-
Open the file iothub_client_sample_amqp.py in a text editor.
-
Locate the following code in the file:
connectionString = "[device connection string]"
-
Replace
[device connection string]
with the connection string for your device. Save the changes. -
Run the sample application using the following command:
python iothub_client_sample_amqp.py
-
The sample application will send messages to your IoT hub. The iothub-explorer utility will display the messages as your IoT hub receives them.
There is a sample to test each of the AMQP, HTTP and MQTT protocols. It is also possible to simply change the transport in the sample.
Visual Studio Code provides an excellent environment to write and debug Python code: