I'm working with Azure Event Grid to receive incoming events from an external publisher. When files are uploaded to a blob container named "snlf", I want my Service Bus trigger Function App to process them.
Current Setup: I use Event Grid to filter events for files under the "snlf" container:
Event Grid System-Topic Configuration:
Metrics: Mapped to a Service Bus queue
Filters: Event Types: Event Created
Subject Filters: Begins with: /blobService/default/containers/snlf/
Ends with: .json
Delivery Properties: Header Name: SessionID Type: Dynamic Value: subject
Problem: Azure Service Bus is rejecting events from Event Grid when the subject length exceeds 128 characters.
Constraints: I need to compress the subject before it reaches the Service Bus. Using Logic Apps or Function Apps for compression is not ideal due to added technical debt.
Question: How can I truncate or compress the subject within Event Grid before it reaches Service Bus? Are there alternative ways to handle this limitation effectively?
Any suggestions or examples would be greatly appreciated!
Solution: Using Event Grid Delivery Properties to Handle Subject Length Limitation I found a solution within Azure Event Grid's Delivery Properties settings. Here's how I resolved the issue:
Issue Recap: When configuring an Event Subscription under an Event Grid System Topic, I initially set the SessionID as the subject in the Delivery Properties. However, since the subject length exceeded 128 characters, Azure Service Bus rejected the events.
Solution: In Event Grid → System Topics → YourSystemTopic → Event Subscriptions → YourEventSubscription, under Delivery Properties, you can choose from predefined dynamic header source fields based on the saved event schema, such as:
Custom properties from the payload (using . as a nesting separator). Since my subject was too long for SessionID, I updated the Delivery Properties to use the Id field instead of Subject. The Id is always less than 20 characters, making it a valid and reliable SessionID for Service Bus.
Outcome: By setting SessionID = Id instead of SessionID = Subject, the Service Bus queue successfully accepted the messages without exceeding the character limit.