Azure stream analytics

Given Mnisi 40 Reputation points
2023-10-19T13:35:01.65+00:00

I get this error when I want to display the data generated from this script Screenshot 2023-10-19 153252

Screenshot 2023-10-19 153202

Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
562 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,639 questions
Azure Stream Analytics
Azure Stream Analytics
An Azure real-time analytics service designed for mission-critical workloads.
331 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,454 questions
Azure Event Grid
Azure Event Grid
An Azure event routing service designed for high availability, consistent performance, and dynamic scale.
318 questions
{count} votes

Accepted answer
  1. Sander van de Velde 29,271 Reputation points MVP
    2023-10-19T19:40:09.2566667+00:00

    Hello @Given Mnisi,

    I tested the code with Visual Studio. It test JSON for me while debugging:

    User's image

    It seems the doubles come with decimal 'comma' instead of decimal point:

    {"vehicle_id": 7941, "timestamp": "2023-10-19 19:25:17", "latitude": -45,8807284588388, "longitude": 90,01136751036734}
    

    Note: I live in The Netherlands, so this could be a regional thing.

    I tested by turning lat and long into integers:

    var latitude = (int) random.NextDouble() * 180 - 90;
    var longitude = (int) random.NextDouble() * 360 - 180;
    
    

    It's probably the string concatenation giving the problem.

    A better way to work with JSON messages is Serialization and Deserialization.

    Here is an example:

    using Newtonsoft.Json;
    
    internal class Program
    {
    	static void Main(string[] args)
    	{
    		Random random = new Random();
    
    		var message = new Message
    		{
    			vehicleId = 1,
    			timestamp = DateTime.Now,
    			latitude = random.NextDouble() * 180 - 90,
    			longitude = random.NextDouble() * 360 - 180
    		};
    
    		var data = JsonConvert.SerializeObject(message);
    
    		Console.WriteLine(data);
    
    		var message2 = JsonConvert.DeserializeObject<Message>(data);
    	}
    }
    
    public class Message
    {
    	public int vehicleId { get; set; }
    	public DateTime timestamp { get; set; }
    	public double latitude { get; set; }
    	public double longitude { get; set; }
    }
    

    The data property is what you will need in your application. Remove that string concatenation.

    Regarding Azure Stream Analytics giving the issue.

    It could be you will have some issues with the corrupt messages still in the pipeline between EventHub and Azure Stream Analytics due to the retention time. Eventually these will be removed.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.


0 additional answers

Sort by: Most helpful