In VS I've created an Azure Web Job. I see a boiler plate method:
static void Main()
{
var host = new JobHost();
// The following code ensures that the WebJob will be running continuously
host.RunAndBlock();
}
Also a function method:
// This function will get triggered/executed when a new message is written
// on an Azure Queue called queue.
public static void ProcessQueueMessage([QueueTrigger("queue")] string message, TextWriter log)
{
log.WriteLine(message);
}
Cool... however I don't want to use Azure Queue or blog storage. I don't need to pass in any data as arguments or trigger it.
I simply want a job that will run every hour and do some data processing. Specially hit a 3rd party API and load some data into my Azure DB.
What am I missing here?
EDIT
Should I just be using a vanilla console app in this situation and publish it as an "Azure Web Job" ?
You should just use a vanilla console app and deploy that as an Azure Web Job. See the steps below:
Source with screenshots: https://azure.microsoft.com/nl-nl/documentation/articles/websites-dotnet-deploy-webjobs/#convert
You can find more information about this here: https://azure.microsoft.com/nl-nl/documentation/articles/websites-dotnet-deploy-webjobs/.
On this page you can also read that a console application can be used as an Azure Web Job by adding the Microsoft.Web.WebJobs.Publish NuGet package and a webjob-publish-settings.json.
Example webjob-publish-settings.json:
{
"$schema": "http://schemastore.org/schemas/json/webjob-publish-settings.json",
"webJobName": "WebJob1",
"startTime": "2014-06-23T00:00:00-08:00",
"endTime": "2014-06-27T00:00:00-08:00",
"jobRecurrenceFrequency": "Minute",
"interval": 5,
"runMode": "Scheduled"
}
When you want to add this Azure Web Job to an existing Azure Web App (website) project you can link the webjob by adding a webjobs-list.json file to the website project.
Example webjobs-list.json:
{
"$schema": "http://schemastore.org/schemas/json/webjobs-list.json",
"WebJobs": [
{
"filePath": "../ConsoleApplication1/ConsoleApplication1.csproj"
},
{
"filePath": "../WebJob1/WebJob1.csproj"
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With