How not to duplicate the IHostedService .Net core 2.2 in scalable microservices?

205 Views Asked by At

I have a subtask with IHostedService in my API and I have a question.

How can I do that whenever there is a new instance in Azure, this service will not be duplicated?

It is a process that sends daily emails. If this doubles then my clients may end up receiving two identical emails.

services.AddSingleton<IHostedService>(provider => new SendScheduledReportsService(provider.CreateScope()));
0

There are 0 best solutions below