Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.35k stars 4.71k forks source link

Support "Promotion" of CloudEvent attributes to Service Bus Headers. #41575

Open Euan-McVie opened 8 months ago

Euan-McVie commented 8 months ago

Library name

Azure.Core

Please describe the feature.

Hi,

We are currently using the CloudEvent type for ServiceBus as per https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/servicebus/Azure.Messaging.ServiceBus/samples/Sample11_CloudEvents.md

In order for us to use a SqlFilter on the subscriber we are creating the service bus message using:

// message is an Azure.Messaging.CloudEvent from the methods parameter.
new ServiceBusMessage(new BinaryData(message))
{
    ContentType = "application/cloudevents+json",
    ApplicationProperties =
    {
        { "ce-type", message.Type },
        { "ce-source", message.Source },
        { "ce-specversion", "1.0" } // Can't use message.SpecVersion as the property is internal :(
    }
});

To help support formally rolling out CloudEvents across other Azure services it would be great if there was an extension to the ServiceBus SDK to help remove some of this boilerplate code so that there would be some form of:

message.ToServiceBusMessage(includeAttributesAsApplicationProperties: true)
jsquire commented 8 months ago

Hi @Euan-McVie. Thank you for reaching out with your suggestion. I've added this to our backlog for consideration.

//cc: @JoshLove-msft, @m-redding