I have attempted to follow the documentation re: replicating events from the primary to the secondary hub while Geo-Disaster Recovery is enabled. I have an alias, and EVH-Primary and EVH-Secondary both sit behind it. EVH-Primary is active; EVH-Secondary is passive.
I am attempting to replicate any events that pass through EVH-Primary by sending the same events through an Azure Function that listens on a "replication" consumer group, and does nothing except forward events to EVH-Secondary; however, when I attempt to do this, I get the following error:
InvalidSignature: This namespace is secondary and read-only.
If the secondary hub is always read-only, what is the point of trying to replicate events to it? Is it a problem with my code?
Here's my C#:
[Function(nameof(EventReplicationFunction))]
public async Task EventReplication([EventHubTrigger("%EventHubs:HubName%", Connection = "EventHubs", ConsumerGroup = "%EventHubsDR:ConsumerGroupReplication%")]
EventData[] eventDataCollection,
FunctionContext context)
{
try
{
if (!IsDrConfigured(logger) || !await IsSecondaryAsync()) return;
logger.LogInformation("{Method} - Received {EventBatchCount} events to replicate", nameof(EventReplicationFunction), eventDataCollection.Length);
var tasks = eventDataCollection.Select(async evt =>
{
evt.Properties["IsReplication"] = 1;
var evhProducerClient = eventBufferClientFactory.CreateClient("Secondary");
await evhProducerClient.EnqueueEventAsync(evt, context.CancellationToken);
});
await Task.WhenAll(tasks);
}
catch (OperationCanceledException)
{
if (context.CancellationToken.IsCancellationRequested)
{
logger.LogWarning("{Method} WARNING: Operation Canceled due to external cancellation request", nameof(EventReplicationFunction));
}
else
{
logger.LogWarning("{Method} WARNING: Operation Canceled", nameof(EventReplicationFunction));
}
}
catch (Exception ex)
{
logger.LogError(ex, LogTemplateType.Error.ExceptionWithStrackTrace, nameof(EventReplicationFunction), ex.Message, ex.StackTrace);
}
}
Including this screenshot per the MS documentation:
InvalidSignature: This namespace is secondary and read-only.
You are getting this error because you have configured Azure Event Hubs - Geo-disaster recovery, which does not replicate the event data and it only replicates the namespace configuration information from primary to a secondary namespace.
You can also refer to the answer given by MayankBargali in this SO which says below.
Event Hub Geo-disaster is only for metadata disaster recovery and not for events in event hub disaster recovery. Geo-disaster is mainly used in the scenario when you don't want to update the connection string in your different applications in case of disaster and saves your time creating the new namespace with all the event hub/configurations and updating the new connection string.
References -