Cloud

Azure Service Bus: qualify a Geo-DR failover before moving the alias

A production runbook for proving Azure Service Bus Geo-DR readiness, bounding message loss, validating the secondary path and choosing safe failover, forced failover or hold.

03 Nov 2026 azureservice-busgeo-drdisaster-recoverymessagingdnsidentityobservabilityautomationrunbookrollbackproduction

An Azure region is degraded and Service Bus producers begin to time out. The secondary namespace is paired, the alias exists, and the incident channel asks for failover. Moving the alias looks like a routing change. It is not: Geo-Disaster Recovery replicates namespace metadata, not messages, and the operation breaks the existing pairing.

The running case is a Premium namespace used by order producers and two consumer groups. The primary still contains active, scheduled and dead-lettered messages. The secondary exists in another region, but the team has never proved its RBAC, private connectivity or consumer behavior. This runbook ends with one of three decisions: execute a safe failover, accept a forced failover with a named data boundary, or hold while the current region remains the least harmful path.

This runbook targets an existing Geo-DR alias. If the requirement is to replicate message data and state between regions, qualify Service Bus Geo-Replication instead; Microsoft recommends it for most disaster recovery scenarios.

Freeze the decision boundary

Record the business deadline, the last healthy operation, current backlog and the evidence that distinguishes a regional Service Bus failure from an application, identity or network failure. Do not make the failover command the diagnostic test.

yaml 01-geo-dr-decision-boundary.yml
incident: INC-MSG-842
detected_utc: 2026-11-03T06:45:00Z
alias: sb-orders-prod
primary: sb-orders-we-prod
secondary: sb-orders-ne-prod
pairing_state: <observed-state>

business_boundary:
last_confirmed_publish_utc: <timestamp>
last_confirmed_consume_utc: <timestamp>
maximum_acceptable_outage: <duration>
accepted_message_loss: <explicit-rpo>

containment:
publishers: paused-or-rate-limited
replay_jobs: disabled
deployment_changes: frozen

decision_owner: <named-owner>
change_reference: CHG-2026-1103-08

If producers can still write while consumers cannot read, continuing publication increases the stranded set. If only one application fails, a namespace failover may move a healthy broker behind the same broken identity, DNS or firewall configuration.

Name what Geo-DR will and will not move

Geo-DR continuously copies queues, topics, subscriptions and their configuration. It does not copy queued messages, dead-letter messages, active sessions or scheduled-message state. RBAC assignments, private endpoint connections, network access settings, managed identities, encryption configuration and Event Grid subscriptions also require independent preparation.

Build the failover contract from the effective production configuration, not from an old architecture diagram.

text 02-replication-contract.txt
EXPECTED ON SECONDARY BEFORE FAILOVER
Queue, topic, subscription and rule definitions
Entity properties and limits
Required RBAC assignments created explicitly
Private endpoints, DNS and network controls tested explicitly
Encryption and identity configuration owned by IaC

NOT MOVED BY GEO-DR
Active, scheduled or dead-lettered messages
Active sessions and their state
Namespace and entity RBAC assignments
Private endpoint connections and public network settings
Managed identities, customer-managed keys and Event Grid subscriptions

AFTER FAILOVER
Alias points to the former secondary
Existing pairing is removed
Recovery proceeds forward with a new secondary

If losing the primary backlog violates the RPO, stop here. Geo-DR is the wrong recovery mechanism for that requirement. A forced failover cannot create data that was never replicated.

Prove the pairing and the endpoint clients use

Inventory the alias from the primary namespace and retain the raw output with the incident evidence. Then inspect application configuration, Key Vault references and deployment variables to prove that every producer and consumer uses the alias FQDN, not a physical namespace hostname.

bash 03-inventory-geo-dr.sh
set -eu

RG="rg-messaging-prod"
PRIMARY="sb-orders-we-prod"
SECONDARY="sb-orders-ne-prod"
ALIAS="sb-orders-prod"

az servicebus georecovery-alias show --resource-group "$RG" --namespace-name "$PRIMARY" --alias "$ALIAS" --output json

az servicebus namespace show -g "$RG" -n "$PRIMARY" --query '{id:id,location:location,sku:sku.name,publicNetworkAccess:publicNetworkAccess}' --output json

az servicebus namespace show -g "$RG" -n "$SECONDARY" --query '{id:id,location:location,sku:sku.name,publicNetworkAccess:publicNetworkAccess}' --output json

The alias is useful only when clients actually use it and DNS resolvers honor the change. Record resolver paths and cache behavior for each application region. Do not lower TTL or flush an estate-wide cache during the incident without first proving stale resolution.

Compare entity metadata and access controls

Wait for metadata synchronization before a planned safe failover. Large namespaces can take time because subscriptions and rules count as entities. Compare the entities that matter to the incident, including filters, session requirements, duplicate detection and auto-delete settings.

bash 04-compare-secondary-contract.sh
set -eu

RG="rg-messaging-prod"
PRIMARY="sb-orders-we-prod"
SECONDARY="sb-orders-ne-prod"

az servicebus queue list -g "$RG" --namespace-name "$PRIMARY" --query '[].{name:name,status:status,session:requiresSession,duplicateWindow:duplicateDetectionHistoryTimeWindow}' --output json

az servicebus queue list -g "$RG" --namespace-name "$SECONDARY" --query '[].{name:name,status:status,session:requiresSession,duplicateWindow:duplicateDetectionHistoryTimeWindow}' --output json

az role assignment list --scope "<secondary-namespace-resource-id>" --include-inherited --query '[].{principal:principalId,role:roleDefinitionName,scope:scope}' --output json

Compare normalized results rather than display order. The secondary should have the same entity contract and only the required send, listen and management roles. Copying every historical assignment from the primary can turn disaster recovery into a privilege expansion.

Validate the secondary path without pretending it is active

Before failover, the Geo-DR secondary is passive. A successful control-plane read does not prove that post-failover send and receive will work. Validate everything that can be validated independently: private endpoint approval, DNS from both application networks, firewall intent, RBAC scopes, managed identity selection and the deployed client configuration.

text 05-secondary-readiness-matrix.txt
CHECK                                      EXPECTED EVIDENCE
Alias state                                pairing is healthy and endpoints are named
Entity metadata                            required queues, topics, subscriptions and rules match
Producer identity on secondary             Azure Service Bus Data Sender at approved scope
Consumer identity on secondary             Azure Service Bus Data Receiver at approved scope
Private path from application VNet          expected private IP and TCP 5671 or 443 reachable
Public access posture                      matches the approved secondary design
CMK and managed identity                    configured and healthy when required
Application configuration                  alias FQDN, not physical namespace FQDN
Synthetic post-failover message             unique ID and idempotent cleanup procedure ready

With private endpoints, the existence of an endpoint on both namespaces is not an end-to-end test. Resolve from the real workload networks and prove the expected IP and path. Private Endpoint is one dependency in this runbook, not the reason to fail over.

Bound the stranded-message problem

Capture queue, topic subscription and dead-letter counts immediately before the decision. Record active-message age where the application exposes it, plus any scheduled jobs or session-based workflows that may be interrupted.

bash 06-freeze-message-boundary.sh
set -eu

RG="rg-messaging-prod"
PRIMARY="sb-orders-we-prod"

az servicebus queue list -g "$RG" --namespace-name "$PRIMARY" --query '[].{name:name,active:countDetails.activeMessageCount,deadLetter:countDetails.deadLetterMessageCount,scheduled:countDetails.scheduledMessageCount}' --output json

az servicebus topic list -g "$RG" --namespace-name "$PRIMARY" --query '[].{name:name,size:sizeInBytes,status:status}' --output json

These counts define the recovery workload; they are not proof that each message can be recovered. After the old primary returns, drain it through a controlled bridge or replay process with stable message identifiers and consumer idempotency. Never connect ordinary producers to both namespaces to improvise active-active delivery during the incident.

Choose safe failover, forced failover or hold

A safe failover waits for pending metadata replication. It requires both namespaces to be in the same Azure subscription and is appropriate only when the primary control plane is available enough to complete synchronization. A forced failover prioritizes activation and can leave recent metadata behind.

Keep the command behind the approved change step. The difference between the two paths must be visible in the incident record.

bash 07-approved-failover-step.sh
set -eu

RG="rg-messaging-prod"
PRIMARY="sb-orders-we-prod"
ALIAS="sb-orders-prod"
SAFE_FAILOVER="true"  # Set false only with an explicit forced-failover decision.

az servicebus georecovery-alias fail-over --resource-group "$RG" --namespace-name "$PRIMARY" --alias "$ALIAS" --is-safe-failover "$SAFE_FAILOVER" --change-reference "CHG-2026-1103-08" --output none

Do not automate this command from one health probe. A regional application failure, an identity outage or a private DNS fault can produce the same symptom while requiring a different recovery action.

Validate the new primary and recover forward

After the alias moves, resolve it from every application network and run one uniquely identified canary through the real producer and consumer code path. Correlate the result with Service Bus metrics and application telemetry. Then increase traffic gradually.

text 08-post-failover-gates.txt
PROMOTE TRAFFIC
Alias resolves through the expected path from each application region
Producer and consumer reconnect without using physical namespace endpoints
One canary is published, consumed once and acknowledged
Sender and receiver identities match the approved principals
Incoming requests, successful requests and server errors return to baseline
Backlog grows and drains as expected under a bounded traffic step
A new secondary and re-pairing change are owned and scheduled

HOLD TRAFFIC
Metadata differs or a required entity is missing
Alias DNS is inconsistent across application networks
RBAC or private connectivity on the new primary is unproven
Consumers are not idempotent enough for later recovery of stranded messages

CONTAIN
Pause publishers or route work to a durable upstream buffer
Keep replay automation disabled
Preserve the pre-failover counts and client correlation IDs
Repair the new primary before widening traffic

There is no in-place rollback to the former primary. Geo-DR uses fail-forward semantics: create a new secondary and pair it with the active namespace. If the old primary recovers, recover its stranded messages as a separate, idempotent data operation. Returning to the original region later requires another planned pairing and failover, with another explicit message boundary.

Conclusion

A Service Bus Geo-DR failover is not a DNS shortcut. It is a one-way control-plane decision that changes the active namespace while leaving message data behind. The operation is justified only when the alias is truly used, secondary metadata and dependencies are ready, the stranded-message boundary is accepted, and the team owns the next pairing.

The closing decision should be explicit: safe failover with synchronized metadata, forced failover with an accepted loss boundary, or hold and repair the actual failing layer. If message continuity is the requirement, redesign around Geo-Replication rather than asking Geo-DR to provide guarantees it does not implement.