Skip to content

feat: Add configurable single event delivery for ServiceBus subscribers#261

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/make-servicebus-message-configurable
Draft

feat: Add configurable single event delivery for ServiceBus subscribers#261
Copilot wants to merge 3 commits intomasterfrom
copilot/make-servicebus-message-configurable

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

Azure EventGrid to ServiceBus delivers events as single JSON objects, not arrays. The simulator always wrapped events in arrays, requiring workarounds in event parsing logic.

Changes

  • IEventSchemaFormatter: Added SerializeSingle() method to serialize events without array wrapper
  • Formatters: Implemented SerializeSingle() in CloudEventSchemaFormatter and EventGridSchemaFormatter
  • ServiceBusSubscriberSettings: Added singleEventDelivery boolean property
  • ServiceBusEventDeliveryService: Uses SerializeSingle() when singleEventDelivery == true

Usage

{
  "serviceBus": [{
    "name": "MySubscriber",
    "queue": "my-queue",
    "singleEventDelivery": true
  }]
}
Configuration Output Notes
true {...} Matches Azure behavior
false or omitted [{...}] Backward compatible (default)
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]: EventGrid to ServiceBus as SingleEvent</issue_title>
<issue_description>### Problem Statement

When EventGrid sends to ServiceBus in Azure, the actual messages on the ServiceBus topic are not arrays with a single item.

In the CloudEventSchemaFormatter, it is hard-coded as sending through as an array of a single item:
https://github.com/pm7y/AzureEventGridSimulator/blob/master/src/AzureEventGridSimulator/Domain/Services/CloudEventSchemaFormatter.cs#L33
So, has an array wrapper in the serialized ServiceBusReceivedMessage.Body.

It would be great if this was configurable to simulate what actually happens in Azure. We've had to add extra logic to check for arrays in our event parser to handle this, which I'd prefer to not be needed.

This is a great project otherwise and really helpful to not have to point to Azure locally.

Proposed Solution

Configuration read in the ServiceBusEventDeliveryService that can be passed to the CloudEventSchemaFormatter or EventGridSchemaFormatter to return as SingleEvent:
https://github.com/pm7y/AzureEventGridSimulator/blob/master/src/AzureEventGridSimulator/Domain/Services/Delivery/ServiceBusEventDeliveryService.cs#L62C17-L62C22

Or change that to the default logic, since that is how EventGrid to ServiceBus message delivery works in Azure.

Alternatives Considered

No response

Feature Category

Configuration

Use Case

EventGrid to ServiceBus topic using CloudEvent schema.

Contribution

  • I would be willing to submit a PR for this feature</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 13, 2026 00:10
- Add SerializeSingle method to IEventSchemaFormatter to serialize single events without array wrapper
- Implement SerializeSingle in CloudEventSchemaFormatter and EventGridSchemaFormatter
- Add singleEventDelivery property to ServiceBusSubscriberSettings
- Update ServiceBusEventDeliveryService to use single event serialization when configured
- Add unit tests for single event serialization

Co-authored-by: pm7y <3075792+pm7y@users.noreply.github.com>
Address code review feedback by adding test for SingleEventDelivery = false

Co-authored-by: pm7y <3075792+pm7y@users.noreply.github.com>
Copilot AI changed the title [WIP] Update configuration for ServiceBus single event messages feat: Add configurable single event delivery for ServiceBus subscribers Feb 13, 2026
Copilot AI requested a review from pm7y February 13, 2026 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: EventGrid to ServiceBus as SingleEvent

2 participants