This is my first time that I've done a WebJob Type of application. I have created a webjob project and in the solution it comes with Program.cs
and Function.cs
.
I have already removed Function.cs
because in this project there is no queue I will be getting data from.
Now in Program.cs
there is already Main Method as the following:
class Program
{
// Please set the following connection strings in app.config for this WebJob to run:
// AzureWebJobsDashboard and AzureWebJobsStorage
static void Main()
{
var host = new JobHost();
// The following code ensures that the WebJob will be running continuously
host.RunAndBlock();
}
}
As I understand, that RunAndBlock
is to run the webjob continuously, but I want the job to run one time only. I want to control the execution from outside by a schedule. I would like to know how to make my code run only one time?
As seen below, I have a SupportService
Class that has RunOnePoolProvisioingCycle
, I want to call this method one time only.
Is this the right approach?
static void Main()
{
SupportService _supportService = new SupportService();
_supportService.Initialize();
_supportService.SetPoolProvisioningConfigurations();
_supportService.RunOnePoolProvisioningCycle();
}
or this one?
static void Main()
{
var host = new JobHost();
SupportService _supportService = new SupportService();
_supportService.Initialize();
_supportService.SetPoolProvisioningConfigurations();
host.Call(typeof(SupportService).GetMethod("SetPoolProvisioningConfigurations"));
}
or this one?
static void Main()
{
var host = new JobHost();
SupportService _supportService = new SupportService();
_supportService.Initialize();
_supportService.SetPoolProvisioningConfigurations();
host.CallAsync(typeof(SupportService).GetMethod("SetPoolProvisioningConfigurations"));
}
or should I use:
host.Start()
or
host.StartAsync()?