Azure Service Bus Topic to Blob read by Stream Analytics

Today, I learned that - although supposedly more efficient - you cannot actually just copy the input stream from a Azure Service Bus BrokeredMessage into a block blob and have that blob be read by Stream Analytics. This is because stream-copy introduces some control characters into the event stream, which makes it so that stream analytics cannot read the events, thinking that maybe you configured your Path Prefix Pattern wrong.


In the example above, notice how I pass CultureInfo.InvariantCulture into the path-generating DateTime expression. This is because DateTime has some magic built in, rending the expression as 2015-09-23-15 for the 23rd of September, 2015 at 15 o'clock on my machine, instead of what I (thought I) requested - 2015/09/23/15. That aside, the resulting blob had control characters and serialization data in it, which was not something I expected:




Extracting the JSON-encoded string itself and uploading that as a byte array, worked a lot better, eliminating both the control characters and the serialization information altogether:



Oh, while I have your attention, I'd like to share my Stream Analytics configuration as well, since that can be a little confusing to begin with:

Notice how I write to a blob named with a date pattern, followed by an hour and a sequence number. This corresponds to a stream analytics Path Prefix Pattern of {date}/{time}, having the Date Format be YYYY/MM/DD and hour format being HH. The BlobContainer you see in the code, is named the same thing as the general/Container configuration, so no magic here.

Alright. That should hopefully get you started (or unstuck!).

Comments

Popular posts from this blog

Auto Mapper and Record Types - will they blend?

Unit testing your Azure functions - part 2: Queues and Blobs

Testing WCF services with user credentials and binary endpoints