Search code examples
azureazure-iot-hubazure-stream-analytics

Stream Analytics: Process compressed and uncompressed data in same job


We are using Stream Analytics to read IoT Messages from IoT Hub. In order to improve bandwidth usage, we want to send the data in a compressed format. I know, stream analytics supports decompression of input streams in gzip and deflate format which is documented here.

However, during a migration period, we might have devices sending both compressed and uncompressed data to IoT Hub and we have to deal with both formats / client versions.

I was thinking about including a metadata property in the client messages to indicate whether the payload is compressed or uncompressed and use IoT Hub routing to route to 2 different Stream Analytics Jobs (one reading compressed format and one reading the data plain), however i don't like the idea of having duplicated Stream Analytics Jobs who only differ in this one setting.

Another idea would be to stream the data through an Azure Function which does the conditional compressing/uncompressing and then forwards the plain messages to Event Hub which serves as a single input to Stream Analytics with input decompression deactivated. The downside to this approach is the cost for the intermediate Azure Function and the architectural change.

Is there an easier way to accomplish this migration scenario?


Solution

  • You might not need two ASA jobs, but maybe you can route messages to the Event Hub, if you add the metadata property, and just add another input(that event hub) to your existing ASA job. For that particular input as an Event Compression Type, you would use GZip for example, and for IoT Hub, potentially would be 'None'.