Azure Web Job - data processing

In VS, I created an Azure Web Job. I see the boiler plate method:

    static void Main()
    {
        var host = new JobHost();
        // The following code ensures that the WebJob will be running continuously
        host.RunAndBlock();
    }

      

Also the 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 any data as arguments or run it.

I just want a job that will run every hour and do some processing on the data. Specifically removed 3rd party API and loaded some data into my Azure DB.

What am I missing here?

EDIT

Should I just use a vanilla console app in this situation and publish it as "Working on the Azure Web"?

+3


source to share


1 answer


You just need to use a vanilla console app and deploy as an Azure Web Job. See the next steps:

  • Right-click the web project in Solution Explorer and select Add> Existing Project as Azure WebJob. The Add Azure WebJob dialog box appears.
  • From the Project Name drop-down list, select the Console Application project to add as a web application.
  • Complete the Add Azure WebJob dialog box and click OK.
  • The Web Publishing Wizard appears. If you don't want to publish immediately, close the wizard. The options you entered are saved when you want to deploy the project.

Source with screenshots: https://azure.microsoft.com/nl-nl/documentation/articles/websites-dotnet-deploy-webjobs/#convert

More information on this can be found here: https://azure.microsoft.com/nl-nl/documentation/articles/websites-dotnet-deploy-webjobs/ .

You can also read on this page that the console app can be used as an Azure Web Job by adding the Microsoft.Web.WebJobs.Publish NuGet package and 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"
}

      

If you want to add this Azure Web Job to an existing Azure Web App (website) project, you can link the website by adding the 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"
    }
  ]
}

      

+3


source







All Articles