Windows IoT


Getting data from IoT hub to Azure Stream Analytics


Hi everyone,
I'm trying to get data sent by my Raspberry Pi to be written to an Azure DocumentDB instance. To do so, I created an IoT event hub to which data is being sent. I've used the Remote Monitoring sample as an inspiration source and got this part working. A console
app I created to read the data from the event hub is receiving the sent data properly, formatted in JSON.
Now I'm trying to hook up an Azure Stream Analytics job to take the data from the hub and transport it to a Document DB. I've got the input, query and output set-up but then the job goes into 'Degraded' state. Within the operation logs, I find the following
message:
"The output record does not contain key property: [deviceproperties.createdtime]. Ensure the query output contains the column [deviceproperties.createdtime]"
If I run the query with some sample data (pasted below), this property is there. So next I looked at the input and tried to generate sample data from it. Whenever I do that (select input, click sample data,
select timerange) it says: "Failed to sample data from 'repsaj-neptune-devicedata'." and the details:
"There was an error while reading sample input. Please check if the input source is configured correctly and data is in correct format.". Whenever I test the input, it says it's fine so that points to an incorrect format of some kind. But
I configured it as JSON and it's sent as JSON, pretty sure about that.
So now I'm stuck on why this is failing and how to resolve it. Is it my json object, some setting or something else? I've got no clue at this point.
Sample data:
{"DeviceProperties":{"DeviceID":"repsaj-neptune-win10pi","HubEnabledState":true,"CreatedTime":"2016-01-06T18:10:20.9395536Z","DeviceState":"normal","UpdatedTime":null,"Manufacturer":"Repsaj Inc."},"Commands":[],"CommandHistory":[],"IsSimulatedDevice":false,"ObjectType":"DeviceInfo","Version":"1.0","Temp1":19.5,"Temp2":20.0,"pH":13.3700027}
{"DeviceProperties":{"DeviceID":"repsaj-neptune-win10pi","HubEnabledState":true,"CreatedTime":"2016-01-06T18:10:51.2364274Z","DeviceState":"normal","UpdatedTime":null,"Manufacturer":"Repsaj Inc."},"Commands":[],"CommandHistory":[],"IsSimulatedDevice":false,"ObjectType":"DeviceInfo","Version":"1.0","Temp1":19.5,"Temp2":20.0,"pH":13.4029255}
{"DeviceProperties":{"DeviceID":"repsaj-neptune-win10pi","HubEnabledState":true,"CreatedTime":"2016-01-06T18:11:21.5489287Z","DeviceState":"normal","UpdatedTime":null,"Manufacturer":"Repsaj Inc."},"Commands":[],"CommandHistory":[],"IsSimulatedDevice":false,"ObjectType":"DeviceInfo","Version":"1.0","Temp1":19.5,"Temp2":20.0,"pH":13.3205872}
{"DeviceProperties":{"DeviceID":"repsaj-neptune-win10pi","HubEnabledState":true,"CreatedTime":"2016-01-06T18:11:51.8614247Z","DeviceState":"normal","UpdatedTime":null,"Manufacturer":"Repsaj Inc."},"Commands":[],"CommandHistory":[],"IsSimulatedDevice":false,"ObjectType":"DeviceInfo","Version":"1.0","Temp1":19.5,"Temp2":20.0,"pH":13.4358273}
Hi J,
I have the following suggestion for you:
What I would suggest is that he creates remote monitoring solution in azureiotsuite.com then look at the input from the ASA that we create as part of the solution. He should
be able to use that to hook up the Event hub to ASA by looking at the input and the query for ASA. For the ASA output, I recommend he check out this article,
https://azure.microsoft.com/en-us/blog/azure-stream-analytics-and-documentdb-for-your-iot-application/. Other than that I would suggest he open a case with the ASA team and let them collaborate as need be.
Sincerely,
IoTGirl
Sorry, lost track of this one.
The answer to the 'degraded' state can be found in the old portal where there is more logging detail available. Here we can check the error and correct it accordingly. The degraded state wasn't occurring any more when I changed the code of my ASA function.
Also, you can only use the input to your ASA job max. 5 times within one query. This is also a reading why a job may be in degraded state (logs will too show this). 
Hi J,
I have the following suggestion for you:
What I would suggest is that he creates remote monitoring solution in azureiotsuite.com then look at the input from the ASA that we create as part of the solution. He should
be able to use that to hook up the Event hub to ASA by looking at the input and the query for ASA. For the ASA output, I recommend he check out this article,
https://azure.microsoft.com/en-us/blog/azure-stream-analytics-and-documentdb-for-your-iot-application/. Other than that I would suggest he open a case with the ASA team and let them collaborate as need be.
Sincerely,
IoTGirl
Hi there,
That is indeed what I have done now; set-up the sample solution alongside it to peek how that works. What I first noticed is that this solution is not writing data to the documentDB instance directly, but has an event hub in between. I'll have to check and
see how that works. Thanks for the pointer, I would suggest you leave the question unanswered so I can provide the proper answer myself in the near future. 
Hi J Siegmund,
As it is now the end of May, I have marked the answer.
Sincerely,
IoTGirl
Sorry, lost track of this one.
The answer to the 'degraded' state can be found in the old portal where there is more logging detail available. Here we can check the error and correct it accordingly. The degraded state wasn't occurring any more when I changed the code of my ASA function.
Also, you can only use the input to your ASA job max. 5 times within one query. This is also a reading why a job may be in degraded state (logs will too show this).

Related Links

Visual Studio 2017 no longer able to compile against Windows.Devices.Gpio
Language support for TTS on windows IoT
Windows 10 IOT Speech languages
Proper setup to generate IoT Image
Cannot Add New Python Project
Daylight Saving Time Issue
Write and read to text file on usb drive in windows iot
failing at the time of driver deployment
Keyboard filter's ForceOffAccessibility does not prevent High Contrast dialog
How to turn off the HDMI USB powered 7" screen
Changing Page Code for Raspberry Pi 3, Visual Studio
Uwp app deployment Raspberry 3
Unable to Preinstall apps on Windows IoT Pro & Update it via Windows Store
Door Ajar/Raspberry/GPIO/Python/C#
Windows 10 IoT Core Pricing
WiFi support for USB devices with external antenna

Categories

MSDN
Windows Phone Dev Center
Commerce Server
Data Platform Development
Feedback and Discussions
Bing Maps
Expression
Archive
Archived Forums I-L
Archived Forums SN-SZ
Where is the Forum For…?
Windows Desktop Develo...
Windows Desktop Sideba...
Windows Imaging Compon...
Development with the W...
SharePoint 2013 - Search
SharePoint Legacy Vers...
Azure SQL Database
Microsoft Azure Site R...
Azure Notification Hubs
Cognitive Services
Azure Security Center
Azure Analysis Services
Azure Log Integration
Azure Time Series Insi...
Windows Communication ...
Team Foundation Server...
Visual FoxPro General
WCF Data Services
Scripting
Internet Explorer Exte...
ISV Open Discussions
Training and Certifica...
Data Mining
SQL Server Data Access
SQL Server XML
Microsoft StreamInsight
SQL Server Data Qualit...
Standard 2009: Embedde...
SQL Server 2012 Setup ...
SQL Server 2012 Integr...
SQL Server 2012 Spatia...
Windows Forms Data Con...
Windows Server 2008 Ap...
Windows Live General: ...
Windows Live  Spaces: ...
CRM
CRM Development
MSDN, TechNet and Expr...
WebsitePanel - Discuss...
Office Protocols
Project Server General...
Microsoft Atlas APIs: ...
Project Standard and P...
Archived: Software Tes...
Building Development a...
Building Windows Store...
App Producer (archived)
Charts & Reports in th...
Chart Controls for .NE...
Hobbyist Zone
(Retired) Exchange Pre...
LightSwitch in Visual ...
JScript for the .NET F...
MS-Build, Multi-Target...
patterns & practices: ...
Popfly Explorer
POS for .NET
Search Server: Feature...
Search, Organize, and ...
Service Bus EAI & EDI ...
SQL Server Modeling
SQL Creation
SQL Server 2014 In-Mem...
Visual Basic Interop a...
Visual Studio Applicat...
Visual Studio Editor i...
Visual Studio Lab Mana...
Web Sandbox - Exploits
Windows CardSpace ('In...
Building Windows Store...
XML Paper Specificatio...
Windows IoT
Windows Containers

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile