0

I have create an application in core net that should be a long running application, implemented as BackgroundService and the project is a Microsoft.NET.Sdk.Worker. In my worker class I delays my ExecuteAsync using the following code:

await Task.Delay(Timeout.Infinite, stoppingToken);

When running the code locally (using docker) it works fine, the application is running until I stop it. However, then I start it under Azure Container Apps (the one in preview right now) the delay task cancels the task right away and my container fails to be deployed.

I can't find any documentation on some limitations for this in container apps, and i don't know what to do differently, as it works in normal docker setup.

aweis
  • 5,350
  • 4
  • 30
  • 46
  • This service is in preview. Features and documentation are currently very early. Ping the team on Twitter with a link to your S.O. question: @AzContainerApp – CSharpRocks Dec 03 '21 at 13:09
  • An earlier question here at SO might provide a hint. Are you sure the container is starting? How about a log message to confirm your code is entered. – camelCase Dec 06 '21 at 22:38
  • I can see in the log workspace that the container is starting, and running the tasks at hand (reading messages from event hub) but when no more messages are available the Task.Delay triggeres an cancel and then the application terminates - the same code works when i move it into a web api solution instead (still as a hosted background service) – aweis Dec 07 '21 at 10:05
  • Can you post the rest of that code? As it looks odd to delay like that. – RubbleFord Dec 08 '21 at 15:59
  • 1
    Have you tried setting "--min-replicas 1", so that atlease one is always active? – ravi Jan 03 '22 at 20:32
  • Did you figure out the solution? It seems I have the same problem with Spring Boot application. It just receives shutdown request right after startup. – Oskars Pakers Feb 28 '22 at 20:51

0 Answers0