At our company, we are onboarding NServiceBus. For several staging environments (e.g., dev, test, int), we would like to use a single Azure Service Bus instance, but prefix the endpoint names with the environment name (e.g., dev-myendpoint).
We are using the installers to create the topologies:
Queues and subscriptions are created per environment based on the endpoint name, which includes the environment prefix(e.g., dev-myendpoint, test-myendpoint).
Topics, however, are created for events based on the event name, which is not prefixed.
As a result, each event ends up with multiple subscribers across environments. For example, if an app publishes an event to the dev environment, it also goes to subscribers in test and int, which is not the intended behavior.
We are looking for best practices/recommendations for using NServiceBus with a single Azure Service Bus instance across multiple environments, with topology separated per environment. Is this a supported scenario, or is it recommended having a separate Azure Service Bus instance per environment?
Yes, generally, separate environments are the recommended setup, not necessarily just for NServiceBus.
Using a single Azure Service Bus instance across Dev, Staging, and Prod creates a high risk of cross-environment interference, where test or staging messages can leak into production queues. It also makes it impossible to enforce proper isolation, governance, and access control policies for each environment, weakening security and compliance.
In addition, because a namespace’s quotas are shared by everything inside it, putting Dev/Staging/Prod together means non-prod traffic can consume connections/ops/storage or hit caps (e.g., QuotaExceededException, throttling), directly degrading or breaking Prod workloads.
Thank you for this information. As I mentioned, it was probably unclear, we would like to use a single instance of Azure Service Bus for environments such as DEV, TST, INT, etc. For PROD, there will be a separate instance of Azure Service Bus.
In this scenario, is the recommendation still to use separate Azure Service Bus instances?
If we still want to use a single instance of Azure Service Bus for DEV, TST, and INT with a topic-per-event topology, what should be done? Or is this not supported?
Yes, it is possible, but be mindful of the tradeoffs. Example: lack of isolation between environments, shared SLA and quotas, sharing of security and so on.
This would be something that you need to research, as it depends on your system/organisation’s requirements.
Ultimately, you would need to compare the benefits against the trade-offs to determine if this is a worthwhile solution.