I have used the below code for converting JSON string to columns in Azure table storage.
'use strict';
// This function is triggered each time a message is received in the IoT hub.
// The message payload is persisted in an Azure storage table
module.exports = function (context, iotHubMessage)
{
context.log('Message received: ' + JSON.stringify(iotHubMessage));
var date = Date.now();
var deviceData = {
"partitionKey": Math.floor(date / (24 * 60 * 60 * 1000)) + '',
"rowKey": date + '',
};
Object.keys(iotHubMessage).forEach(function(key) {
deviceData[key] = iotHubMessage[key];
});
context.bindings.outputTable = deviceData;
context.done();
};
This still shows failure as below:
2017-10-27T06:27:02.134 Exception while executing function: Functions.fnConvertJsonToTable. Microsoft.Azure.WebJobs.Host: Error while handling parameter _binder after function returned:. Microsoft.WindowsAzure.Storage: Element 0 in the batch returned an unexpected response code. 2017-10-27T06:27:02.196 Function completed (Failure, Id=7870d04d-4cc2-4474-8ffa-d67add613f6c, Duration=145ms)
Please suggest the correct solution. Thanks in advance.