Skip to content

Bind DocumentPublishingFunction to ServiceBusReceivedMessage#19

Merged
christopherhouse merged 1 commit into
mainfrom
refactor/function-received-message
May 29, 2026
Merged

Bind DocumentPublishingFunction to ServiceBusReceivedMessage#19
christopherhouse merged 1 commit into
mainfrom
refactor/function-received-message

Conversation

@christopherhouse
Copy link
Copy Markdown
Owner

Summary

Drops the string body binding on DocumentPublishingFunction.Run in favour of the full ServiceBusReceivedMessage, mirroring how DeadLetterHandlerFunction already binds. Gives the function direct access to:

  • MessageId
  • DeliveryCount (retry counter)
  • EnqueuedTime (publisher → processed wall latency)
  • ApplicationProperties (where the Diagnostic-Id lives, even though the AI extension already extracts it)

Enriches the DocumentPublished custom event accordingly:

  • Properties.MessageId
  • Properties.DeliveryCount
  • Metrics.enqueueLatencyMs

Same fields tagged onto the function's invocation Activity (messaging.servicebus.message_id, messaging.servicebus.delivery_count).

Tests now call the internal ProcessAsync directly (same pattern as DeadLetterHandlerFunctionTests), so we don't need to mock or model-factory a ServiceBusReceivedMessage. New assertions cover the added dimensions/metrics.

Test plan

  • dotnet build — clean.
  • dotnet format --verify-no-changes — clean.
  • dotnet test tests/Function.Tests — 13/13 pass.
  • After merge: function-app workflow ships the new binding. Then re-run a publisher event or the integration workflow and confirm the new event carries MessageId, DeliveryCount, and enqueueLatencyMs.

🤖 Generated with Claude Code

Drops the `string body` binding in favour of the full
ServiceBusReceivedMessage so the function has direct access to
MessageId, DeliveryCount, EnqueuedTime, and ApplicationProperties
without going back through the runtime's binding context.

While the new fields were in hand, enriched the DocumentPublished
custom event:
- Properties.MessageId
- Properties.DeliveryCount (useful for observing retry behaviour)
- Metrics.enqueueLatencyMs (publisher -> processed wall time)

Same fields tagged onto the function's invocation Activity so the
end-to-end map shows them.

Tests now call `ProcessAsync` directly (mirrors DeadLetterHandler
test pattern) so we don't need to mock ServiceBusReceivedMessage.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@christopherhouse christopherhouse merged commit 8d477ab into main May 29, 2026
4 checks passed
@christopherhouse christopherhouse deleted the refactor/function-received-message branch May 29, 2026 17:07
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.

1 participant