Search code examples
azure-functionsazure-webjobsazure-webjobssdk

Is it possible to convert Azure function to Azure webjob


Is it possible to convert Azure function to Azure Webjob? as example, can following azure function covert to azure job?

public class Functions
    {
        // This function will get triggered/executed when a new message is written 
        // on an Azure Queue called queue.
        public static void ProcessQueueMessage([ServiceBusTrigger("testsbqueuexxx") ] string message, TextWriter log)
        {
            log.WriteLine($"[WebJobNotificationProcessor-]-{message}");
        }
    }

Solution

  • First of all: why would you want that? You can have your Function run on an existing App Service, too. Have a look at the hosting options you have for Functions in Azure Functions scale and hosting.

    Second: I don't think you can, since the trigger is not available for WebJobs. There are two types of webjobs: continuous and triggered. As far as a triggered webjob go, it...

    Starts only when triggered manually or on a schedule.

    Source: Run background tasks with WebJobs in Azure App Service

    You could, of course, do away with the trigger and move to a continuous webjobs that polls the queue, but you will be throwing away a lot of stuff that the Functions runtime abstracts away for you like connecting to the Service Bus, checking the queue, managing locks and completing or deferring messages.