Colin
Colin

Reputation: 4135

How Do I Deploy A Constantly-Running Application To Azure Service Fabric?

I want to create a program that runs constantly and checks a status every minute or so, then calls a separate service if a condition is met.

Could this work in Azure Service Fabric?

I started looking into how to try to do it as a "Guest Executable" but I'm not sure I'm headed in the right direction.

I'm trying to keep things PaaS, not full-blown IaaS via VM with a Windows Service or something.

Upvotes: 0

Views: 469

Answers (1)

LoekD
LoekD

Reputation: 11470

Services in Service Fabric are always running. So, you can simply use the method RunAsync inside a Service, to run a loop.

protected override async Task RunAsync(CancellationToken cancellationToken)
{
      while (true)
      {                
            cancellationToken.ThrowIfCancellationRequested();
            DoStuff();
            await Task.Delay(TimeSpan.FromSeconds(60),cancellationToken);
      }
}

Upvotes: 2

Related Questions