Skip to content

Resolve Azure Service Bus Geo-Recovery aliases through ARM - #6197

Open
johnsimons wants to merge 1 commit into
masterfrom
john/asb_geo_recovery_alias
Open

johnsimons wants to merge 1 commit into
masterfrom
john/asb_geo_recovery_alias

Conversation

@johnsimons

@johnsimons johnsimons commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Usage collection now resolves an Azure Service Bus Geo-Recovery alias through Azure Resource Manager (ARM) instead of a DNS lookup. Microsoft is moving Service Bus to partitioned DNS, and the DNS lookup fails for any alias that has no servicebus.windows.net record.

Microsoft announced the move in Upcoming DNS changes for Azure Event Hubs and Azure Service Bus, with details in Partitioned DNS. New namespaces get a hostname such as <namespace>.z<N>.servicebus.azure.net. In the final stage, new namespaces get no <namespace>.servicebus.windows.net record. Existing namespaces keep their legacy hostname until they are deleted. Microsoft gives no dates for the stages.

Why only the alias lookup needs a change

ServiceControl hardcodes the legacy Service Bus domain for each Azure cloud in AzureQuery, and sample connection strings use servicebus.windows.net. Apart from the alias lookup, the code works with partitioned hostnames:

  • The transport hands the connection string or fully qualified namespace to the Azure SDK unchanged. Nothing checks the host suffix, so ingestion, retries, queue length and the dead-letter check work with either format.
  • The usage collector takes the namespace name from the first label of the host, which is the same in both formats.
  • The domain table only serves the alias lookup added in Support Azure Service Bus Geo-Recovery alias for querying queue names #4938. When the configured name is a namespace, it matches directly. When the legacy record is missing, DnsClient returns an empty answer and the lookup adds nothing.

The alias lookup queried <alias>.servicebus.windows.net, or the sovereign domain picked from ASB/ManagementUrl, for a CNAME. It accepted the target only if it ended in that same legacy domain. An alias with only a partitioned record resolves to nothing, so GetQueueNames throws Could not find a Azure Service Bus namespace named "<alias>" and usage collection fails.

The change

FindNamespace first matches the configured name against the namespaces in the subscription. If none matches, it reads each namespace's disaster recovery configurations. It picks the namespace that holds the alias with the role Primary, or PrimaryNotReplicating after a failover, and never the secondary. The lookup no longer depends on DNS or on the cloud, so the domain table and the DnsClient package are removed.

Constraints

  • A name match never reads disaster recovery configurations, so a connection without an alias needs no new permission. A test fails if the lookup reads them in that case.
  • Reading disaster recovery configurations needs Microsoft.ServiceBus/namespaces/disasterRecoveryConfigs/read. The Monitoring Reader role that the docs recommend includes it. The minimal custom role on the usage reporting setup page does not, and an alias user with that role gets an error that names the missing permission. The docs change is in Add disasterRecoveryConfigs permission for Geo-Recovery alias support docs.particular.net#8715.
  • The not-found message becomes Could not find an Azure Service Bus namespace or Geo-Recovery alias named "<name>".

Alternatives considered

  • Keep DNS and query the host from the connection string. Microsoft says not to assume zone names in other clouds and does not publish how aliases resolve under partitioned DNS, so the result cannot be verified.
  • Try ARM first and fall back to DNS when the permission is missing. The minimal custom role would keep working unchanged, but the DNS guesswork and the domain table would stay.

Verification

  • FindNamespaceTests fakes the SDK resources. It covers a name match, an alias before and after a failover, an alias seen only on the secondary, and forbidden reads. Against master's lookup, the three alias resolution tests failed with the error above. They pass with this change.
  • The ASB integration tests need live credentials and run in CI. RunScenario and TestConnectionWithValidSettings cover the name match against a real namespace.
  • I have not tested against a real Geo-Recovery pairing.

… lookup

Replaces the DnsClient-based CNAME lookup used to match namespace aliases with a direct ARM query that checks each namespace's disaster recovery aliases. This finds the primary namespace when the configured name is a Geo-Recovery alias, including after a failover, and surfaces a clear error when the required disasterRecoveryConfigs/read permission is missing. Drops the now-unused DnsClient dependency.
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