How to do it...

We will create a device simulator to upload one sample batch telemetry data file, but before this, we need to first configure the IoT Hub. So, let's start with the steps as follows:

  1. To configure IoT Hub, we need to log into the Azure portal.
  2. Select IoT Hub service and navigate to the message section.
  3. Select the File upload option; it will open a new blade in the Azure portal.
  1. Select the storage account and the container for your file ingestion:
File upload configuration
  1. Now, let's initiate the file upload from a device simulator:
using (var telemetryData = new FileStream(telemetryDataFile, FileMode.Open))
{
await deviceClient.UploadToBlobAsync(telemetryDataFile, telemetryData);
}
  1. The IoT Hub will receive the file upload notification and we will process that using the following code:
var notificationReceiver = serviceClient.GetFileNotificationReceiver();
while (true)
{
var fileUploadNotification = await notificationReceiver.ReceiveAsync();
if (fileUploadNotification == null) continue;

var downoadFile = fileUploadNotification.BlobName;
// Download the File uploaded on Blob storage
// process the File data
// ......
// ......

await notificationReceiver.CompleteAsync(fileUploadNotification);
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.116.20