I have an Azure function with an Event Hub trigger. This hub receives messages from devices and stores them in Blob. Recently, I noticed that duplicate messages were stored in blob. Files in blob store are order by last modified date and if you look at the screenshot, you can see that's not the case. Has anyone seen this issue before?
I also have an Azure function that is writing to cosmos DB and for the duplicate messages in blob there is not corresponding duplicate message in cosmos.
I have also hooked up time series insights which also doesn't have any duplicate messages.
I turned on the event hub capture and there are no duplicate messages there as well.
Here's the screenshot.
The first column is the unix timestamp of enqueued time at the event hub. If I didn't have the guid associated with the filename it would have thrown an exception. Here's a snippet that stores data in blob.
dynamic msg = JObject.Parse(myEventHubMessage);
string deviceId = msg.deviceId;
if (deviceId == "5Y.....")
{
var filename = "_" + ((DateTimeOffset)enqueuedTimeUtc).ToUnixTimeSeconds() + "_" + Guid.NewGuid().ToString() + ".json";
var containerName = "containerName/";
var path = containerName + deviceId + "/" + filename;
using (var writer = binder.Bind<TextWriter>(new BlobAttribute(path)))
{
writer.Write(myEventHubMessage);
}
}
The logic here is very simple. If an event comes to the event hub, the function is triggered and it stores data in Azure Blob.