feat: support existing Service Bus namespace with owned queue in event-handler#1083
Merged
Merged
Conversation
despock
requested review from
hemalshah-gradientedge and
jameswiltshire
as code owners
June 9, 2026 13:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds per-resource
useExistingflags on the event-handler construct'sserviceBusprop so a stack can reuse an externally-provisioned Service Bus namespace while still owning its queue and per-queueauthorization rule.
This enables consumers to consolidate many per-stack namespaces (one per function app) onto a smaller set of shared per-domain namespaces, while keeping queue lifecycle and access scoping with each stack.
Changes
construct/event-handler/types.tsEventHandlerServiceBusNamespacePropsandEventHandlerServiceBusQueueProps, each extending the base props with an optionaluseExisting?: boolean.queueAuthorizationRule?: QueueAuthorizationRuleonEventHandlerServiceBus.serviceBus.useExistingretained as a deprecated alias (TODO marker added for removal once consumers migrate).construct/event-handler/main.tsresolveServiceBusUseExisting()helper consolidating the per-resource flag resolution. Per-resource flags take precedence over the deprecated top-level alias.namespace.useExisting=false+queue.useExisting=true(queue cannot be external if its parent isn't).namespace.resourceGroupNamewhen the namespace is existing (previously always used the construct's RG, which broke external-namespace cases).createEventGridEventSubscriptionandcreateServiceBusDiagnosticLognow predicate on the resolved per-resource flag instead of the top-level alias.createServiceBusQueueAuthorizationRule()creates a per-queue rule named${this.id}-listen-sendwith[Listen, Send]rights when the construct owns the queue. Scopes Listen/Send permissions to a singlequeue rather than the namespace's root rule.
createFunctionAppSiteConfigrefactored to use a newresolveServiceBusConnectionString()helper that resolves to the per-queue rule's connection string when present, falling back to the existing behaviourotherwise.
services/servicebus/{main,types}.tscreateServiceBusQueueAuthorizationRule()method andServiceBusQueueAuthorizationRulePropstype onAzureServiceBusManager.services/authorisation/constants.tsAZURE_SERVICE_BUS_DATA_OWNERrole definition id (/providers/Microsoft.Authorization/roleDefinitions/090c5cfd-751d-490a-894a-3ce6f1109419) for stacks that grant the regional SPN owner rights on sharednamespaces.
Backwards compatibility
serviceBus.useExisting=true|falsecontinue to work unchanged - the alias resolves to both per-resource flags.serviceBus.namespace/serviceBus.queueconfig still default to the historical "create both" behaviour.