0

Have an all RESTful service built using .NET core 1.1. No front end. This includes a couple of background tasks that run every other hour. These tasks get bootstrapped (invoked) under the Configure method in the Startup class.

For some reason, nothing gets called when I publish my app onto Azure. It seems that nothing gets runned in the Startup class at all. I have to explicitly invoke a RESTful service to "start" it up and then everything seems to run fine.

I believe I'm doing something wrong here. Is there a way to bootstrap my background tasks immediately when application gets published onto Azure? I don't want to have to manually invoke a rest service just for the app to start up.

Los Morales
  • 2,061
  • 7
  • 26
  • 42
  • https://stackoverflow.com/questions/12154402/configuring-an-azure-website-with-application-warmup have you seen this? – 4c74356b41 Aug 08 '17 at 20:43
  • You should use a WebJob for running taks instead of the App itself: https://blogs.msdn.microsoft.com/benjaminperkins/2017/03/07/how-to-deploy-a-net-core-console-application-to-azure-webjob/ – Fals Aug 08 '17 at 20:44
  • @4c74356b41 That looks like the right idea but it didn't work for me since I don't have an initializationPage to point to. I also just tried this: but that didn't work either. – Los Morales Aug 08 '17 at 21:46

1 Answers1

0

tasks get bootstrapped (invoked) under the Configure method in the Startup class.

You could manage to make it work, if the application runs inside a single instance. All you have to do is ping it from external service like monitis.

However, we need to deploy two or more instances in Azure to avoid a single point of failure. That means we should not run Background Tasks inside those instances; otherwise, we will end up with race condition.

For Background Tasks, you might want to consider using -

Win
  • 61,100
  • 13
  • 102
  • 181