|
| 1 | +--- |
| 2 | +title: Parsing Protobuf |
| 3 | +description: This article describes how to use Azure Stream Analytics with protobuf as a data input |
| 4 | +ms.service: stream-analytics |
| 5 | +author: enkrumah |
| 6 | +ms.author: ebnkruma |
| 7 | +ms.topic: conceptual |
| 8 | +ms.date: 11/13/2023 |
| 9 | +ms.custom: |
| 10 | +--- |
| 11 | +# Parse Protobuf in Azure Stream Analytics |
| 12 | + |
| 13 | +Azure Stream Analytics supports processing events in protocol buffer data formats. You can use the built-in protobuf deserializer when configuring your inputs. To use the built-in deserializer, specify the protobuf definition file, message type, and prefix style. |
| 14 | + |
| 15 | +To configure your stream analytics job to deserialize events in protobuf, use the following guidance: |
| 16 | + |
| 17 | +1. After creating your stream analytics job, click on **Inputs** |
| 18 | +1. Click on **Add input** and select what input you want to configure to open the input configuration blade |
| 19 | +1. Select **Event serialization format** to show a dropdown and select **Protobuf** |
| 20 | + |
| 21 | +:::image type="content" source="./media/protobuf/protobuf-input-config.png" alt-text=" Screenshot showing how to configure protobuf for an ASA job." lightbox="./media/protobuf/protobuf-input-config.png" ::: |
| 22 | + |
| 23 | +Complete the configuration using the following guidance: |
| 24 | + |
| 25 | +| Property name | Description | |
| 26 | +|------------------------------|-------------------------------------------------------------------------------------------------------------------------| |
| 27 | +| Protobuf definition file | A file that specifies the structure and datatypes of your protobuf events | |
| 28 | +| Message type | The message type that you want to deserialize | |
| 29 | +| Prefix style | It is used to determine how long a message is to deserialize protobuf events correctly | |
| 30 | + |
| 31 | +:::image type="content" source="./media/protobuf/protobuf.png" alt-text=" Screenshot showing how protobuf dropdown in the input configuration blade of an ASA job." lightbox="./media/protobuf/protobuf.png" ::: |
| 32 | + |
| 33 | +> [!NOTE] |
| 34 | +> To learn more about Protobuf datatypes, visit the [Official Protocol Buffers Documentation](https://protobuf.dev/reference/protobuf/google.protobuf/) . |
| 35 | +> |
| 36 | +
|
| 37 | +### Limitations |
| 38 | + |
| 39 | +1. Protobuf Deserializer takes only one (1) protobuf definition file at a time. Imports to custom-made protobuf definition files aren't supported. |
| 40 | + For example: |
| 41 | + :::image type="content" source="./media/protobuf/one-proto-example.png" alt-text=" Screenshot showing how an example of a custom-made protobuf definition file." lightbox="./media/protobuf/one-proto-example.png" ::: |
| 42 | + |
| 43 | + This protobuf definition file refers to another protobuf definition file in its imports. Because the protobuf deserializer would have only the current protobuf definition file and not know what carseat.proto is, it would be unable to deserialize correctly. |
| 44 | + |
| 45 | +2. Enums aren't supported. If the protobuf definition file contains enums, then protobuf events deserialize, but the enum field is empty, leading to data loss. |
| 46 | + |
| 47 | +3. Maps in protobuf are currently not supported. Maps in protobuf result in an error about missing a string key. |
| 48 | + |
| 49 | +4. When a protobuf definition file contains a namespace or package, the message type must include it. |
| 50 | + For example: |
| 51 | + :::image type="content" source="./media/protobuf/proto-namespace-example.png" alt-text=" Screenshot showing an example of a protobuf definition file with a namespace." lightbox="./media/protobuf/proto-namespace-example.png" ::: |
| 52 | + |
| 53 | + In the Protobuf Deserializer in portal, the message type must be **namespacetest.Volunteer** instead of the usual **Volunteer**. |
| 54 | + |
| 55 | +5. When sending messages that were serialized using Google.Protobuf, the prefix type should be set to base128 since that is the most cross-compatible type. |
| 56 | + |
| 57 | +6. Service Messages aren't supported in the protobuf deserializers. Your job throws an exception if you attempt to use a service message. |
| 58 | + For example: |
| 59 | + :::image type="content" source="./media/protobuf/service-message-proto.png" alt-text=" Screenshot showing an example of a service message." lightbox="./media/protobuf/service-message-proto.png" ::: |
| 60 | + |
| 61 | +8. Current datatypes not supported: |
| 62 | + * Any |
| 63 | + * One of (related to enums) |
| 64 | + * Durations |
| 65 | + * Struct |
| 66 | + * Field Mask (Not supported by protobuf-net) |
| 67 | + * List Value |
| 68 | + * Value |
| 69 | + * Null Value |
| 70 | + * Empty |
| 71 | + |
| 72 | +> [!NOTE] |
| 73 | +> For direct help with using the protobuf deserializer, please reach out to [[email protected]](mailto:[email protected]). |
| 74 | +> |
| 75 | +
|
| 76 | +## See Also |
| 77 | +[Data Types in Azure Stream Analytics](/stream-analytics-query/data-types-azure-stream-analytics) |
0 commit comments