Set Retry Option for EventGrid EventGridPublisherClient

Viewed 60

I would like to set retry as part of ClientOptions while initializing EventGridPublisherClient. I see that we can pass EventGridPublisherClientOptions which inherits ClientOptions but that read only get property and i dont see we can set as part of constructor as well. Is there a way that we can set retry. We are trying to see if we can retry whe nwe recevie 429 or any transient error.

1 Answers

Maybe you can try something like this :

            var options = new EventGridPublisherClientOptions();
            options.Retry.Mode = Azure.Core.RetryMode.Exponential;
            options.Retry.Delay = TimeSpan.FromSeconds(2);
            options.Retry.MaxRetries = 5;

            var client = new EventGridPublisherClient(
                new Uri(_eventGridConfiguration.TopicEndpoint),
                new AzureKeyCredential(_eventGridConfiguration.SasKey),
                options);
Related