This document is known to be outdated
The following procedure describes the process of connecting a Raspberry Pi 2 device running the Raspbian OS and building the Event Hubs SDK samples (send and send_batch).
- SSH client on your desktop computer, such as PuTTY, so you can remotely access the command line on the Raspberry Pi.
- Required hardware:
- Raspberry Pi 2
- 8GB MicroSD Card
- A USB keyboard
- A USB mouse
- A USB Mini cable
- A 5 Volt - 1 Amp USB power supply
- An HDMI cable
- TV/ Monitor that supports HDMI
- An Ethernet cable or WiFi dongle
Note: You may wish to consider a Starter Kit such as CanaKit that includes some of these hardware requirements.
To run the sample applications you will need an Event Hub to which they can send messages.
To configure an Event Hub, see Create an Event Hub. Be sure to make a note of the Event Hub name and the SendRule and ReceiveRule connection strings; you will need them to complete building the samples.
- Install the latest Raspbian operating system on your Raspberry Pi 2 by following the instructions in the NOOBS setup guide.
- When the install process is complete, the Raspberry Pi configuration menu (raspi-config) loads. Here you can perform tasks such as: set the time and date for your region, enable a Raspberry Pi camera board, and create users. Under Advanced Options make sure to enable ssh so you can access the device remotely with PuTTY or WinSCP from your desktop machine. For more information, see https://www.raspberrypi.org/documentation/remote-access/ssh/.
- Connect your Raspberry Pi to your network either by using an ethernet cable or by using a WiFi dongle on the device.
- You need to discover the IP address of your Raspberry Pi before your can connect using PuTTY. For more information see https://www.raspberrypi.org/documentation/troubleshooting/hardware/networking/ip-address.md.
- Once you see that your board is alive, open an SSH terminal program such as PuTTY on your desktop machine.
- Use the IP address from step 4 as the Host name, Port=22, and Connection type=SSH to complete the connection.
- When prompted, log in with username pi, and password raspberry.
-
Open a PuTTY session and connect to the board, as described in the previous section.
-
Install the prerequisite packages by issuing the following commands in your PuTTY session:
sudo apt-get update
sudo apt-get install -y curl libcurl4-openssl-dev uuid-dev uuid g++ make cmake git
Note: In Windows, you can right-click on a PuTTY window to paste in commands.
- Download the SDK to the board by issuing the following command in your PuTTY session:
git clone --recursive https://github.com/Azure/azure-event-hubs.git
You will be prompted for your GitHub username and password -- if you have two-factor authentication enabled for your account, you'll need to generate and then use a personal access token in place of your password.
- Verify that you now have a copy of our source code under the directory ~/azure-event-hubs.
Before performing these steps, you'll need the following prerequisite information:
- Event Hub name.
- Event Hub SendRule connection string.
Now, configure the sample:
- On the board, run the following command:
nano azure-event-hubs/c/eventhub_client/samples/send/send.c
-
This launches a console-based text editor. Scroll down to the connection information.
-
Replace the placeholder value for the connectionString variable (you can right-click a PuTTY window to paste a value) with your SendRule Event Hub connection string. Replace the placeholder value for the eventHubPath variable with your Event Hub name.
-
Save your changes by pressing Ctrl+O, and when nano prompts you to save it as the same file, just press ENTER.
-
Press Ctrl+X to exit nano.
-
Repeat the previous steps, but for step 1 run the following command, and paste your connection information in the same places:
nano azure-event-hubs/c/eventhub_client/samples/send_batch/send_batch.c
You can now build the SDK samples using the following command:
~/azure-event-hubs/c/build_all/linux/build.sh
- Run the send sample by issuing the following command:
~/azure-event-hubs/c/eventhub_client/samples/send/linux/send
- Run the send_batch sample by issuing the following command:
~/azure-event-hubs/c/eventhub_client/samples/send_batch/linux/send_batch
- For each sample, verify that the sample output messages show Successful. If not, then you may have incorrectly pasted the Event Hub connection information.
Note: The tools folder in this repository includes the CSharp_ConsumeEventsFromEventHub C# application that can receive messages from an Event Hub. This is useful to help you verify that the samples are sending messages correctly to the Event Hub.