Edit

Configure geo-disaster recovery for Azure Event Hubs

This article shows you how to set up geo-disaster recovery pairing between Event Hubs namespaces and initiate failover. For conceptual information about this feature, see Geo-disaster recovery overview.

Prerequisites

  • An Azure subscription. If you don't have one, create a free account before you begin.
  • An Event Hubs namespace (Standard, Premium, or Dedicated tier). The Basic tier doesn't support geo-disaster recovery.

Set up geo-disaster recovery pairing

To set up geo-disaster recovery, you create or use an existing primary namespace, create a secondary namespace in a different region, and then pair the two. This pairing gives you an alias that you can use to connect. Because you use an alias, you don't have to change connection strings.

Note

Only new namespaces can be added to your failover pairing.

Diagram showing the overview of geo-disaster recovery failover process.

  1. Create the primary namespace.

  2. Create the secondary namespace in a different region. This step is optional. You can create the secondary namespace while creating the pairing in the next step.

  3. In the Azure portal, navigate to your primary namespace.

  4. Select Geo-recovery on the left menu, and select Initiate pairing on the toolbar.

    Screenshot that shows the Geo-recovery page for an Event Hubs namespace with Initiate Pairing button selected.

  5. On the Initiate pairing page, follow these steps:

    1. Select an existing secondary namespace or create one in a different region.
    2. For Alias, enter an alias for the geo-dr pairing.
    3. Select Create.

    Screenshot that shows the selection of the secondary namespace for pairing.

  6. On the Geo-DR Alias page, select Shared access policies on the left menu to access the primary connection string for the alias. Use this connection string instead of using the connection string to the primary or secondary namespace directly.

    Screenshot that shows the Geo-DR Alias page showing both the primary and secondary namespaces.

Finally, add monitoring to detect if a failover is necessary. In most cases, the service is one part of a large ecosystem, and automatic failovers are rarely possible because failovers must often be performed in sync with the remaining subsystem or infrastructure.

Initiate failover

When you initiate the failover, two steps are required:

  1. Set up another passive namespace and update the pairing so you can fail over again if another outage occurs.
  2. Pull messages from the former primary namespace once it's available again. After that, use that namespace for regular messaging outside of your geo-recovery setup, or delete the old primary namespace.

Note

Only fail-forward semantics are supported. When you initiate a failover with geo-disaster recovery, you can optionally re-pair with a new namespace after failover completes. Failing back to the previous primary replica isn't supported.

Diagram showing the failover flow.

  1. In the Azure portal, navigate to your primary namespace.

  2. Select Geo-recovery on the left menu.

  3. Select Failover on the toolbar.

    Warning

    Failing over activates the secondary namespace and removes the primary namespace from the geo-disaster recovery pairing. Create another namespace to have a new geo-disaster recovery pair.

Break pairing

If you made a mistake (for example, you paired the wrong regions during the initial setup), you can break the pairing of the two namespaces at any time.

  1. In the Azure portal, navigate to your primary namespace.

  2. Select Geo-recovery on the left menu.

  3. Select Break pairing on the toolbar.

    Screenshot that shows the Break Pairing and Failover menus on the Event Hubs Geo-DR Alias page.

If you want to use the paired namespaces as regular namespaces, delete the alias.