Azure service bus publish to different/multiple topics

By default messages are published to bundle-1 or I can set the topic name myself via transport.TopicName…however, how would I publish to a different topic (or even multiple topics)?

I checked PublishOptions but can’t see anything obvious or similar to SetDestination in SendOptions

NServiceBus Azure Service Bus transport does not require multiple topics for one or more endpoints to subscribe to an event. The topology is intentionally designed to leverage a single topic.

Could you elaborate on what you are trying to achieve and how publishing to multiple topics would help your case?

Frustratingly this is what I’ve been asked to do. The topics and subscriptions have been created via a script and they’re being monitored by azure functions - this was setup via another team.

In order to get it working…don’t use the messageHandlerContext publish. Write my own publish using the native Microsoft.Azure.ServiceBus TopicClient. This way I can pass in the topicName/entryPath.

Reading through

The topics and subscriptions have been created via a script and they’re being monitored by azure functions - this was setup via another team.

and

In order to get it working…don’t use the messageHandlerContext publish. Write my own publish using the native Microsoft.Azure.ServiceBus TopicClient. This way I can pass in the topicName/entryPath.

does that mean you have a different team that has a non NServiceBus Function that needs to subscribe to an event published by one of the NServiceBus endpoints?

Yes and they’ve already created the topics and subscriptions. Which I know goes against pub/sub. I was just hopeful there would be a way to specify the topicName on publish…similar to SetDestination in SendOptions

An event is commonly published to a single topic and doesn’t need to be published to two. When a need is to fan out that event, you could set up a subscription on the topic used by NServiceBus and configure the auto-forwarding to any arbitrary destination you’d like (topic or a queue). You can control wherever a specific message or all messages will be auto-forwarded to the other team’s topic on that custom subscription.

Should you require more details, I’d advise opening a support case at Support options • Particular Software, referring to this thread.

The other team could also run their Function with NServiceBus and would not need to go through this hassle. Let them know about NServiceBus support for Functions (Azure Functions with Azure Service Bus • NServiceBus.AzureFunctions.InProcess.ServiceBus • Particular Docs).

Have a great day.

Thank you @SeanFeldman

Anyone looking for a general native ASB pub/sub integration sample, it’s available here.