Anonymous1
Anonymous1

Reputation: 3907

HTTP Request/Response on Azure WebJob

I'm looking to create a WebJob that takes in a request and sends a response, much like an Azure Function with an HTTP trigger. I want to use a WebJob instead because I need to use wkhtmltopdf, which cannot run on a Consumption plan, and we are already paying for an App Service that it can run on.

I know how to run the WebJob using an HTTP POST from this link: https://stackoverflow.com/a/42824776/443044.

What I cannot figure out is how to create the WebJob itself.

Here is my Program class:

public class Program
{

    [NoAutomaticTrigger]
    public static void TestMethod(TextWriter logger)
    {
        logger.WriteLine("TEST: " + req.Content.ToString());
    }

    // Please set the following connection strings in app.config for this WebJob to run:
    // AzureWebJobsDashboard and AzureWebJobsStorage
    static void Main()
    {
        var config = new JobHostConfiguration();

        ...

        var host = new JobHost(config);
        host.Call(typeof(Program).GetMethod("TestMethod"), null);
    }
}

The program throws an exception if I try to give TestMethod the return type of HttpResponseMessage or a parameter of type HttpRequestMessage.

How can I achieve the request/response functionality like with an Azure Function?

Upvotes: 0

Views: 2616

Answers (1)

Peter Bons
Peter Bons

Reputation: 29840

we are already paying for an App Service -> You do realize you can host your azure function on an existing app plan as well? learn.microsoft.com/en-us/azure/azure-functions/….

But AFAIK webjobs do not have capabilities to respond to requests.

Upvotes: 3

Related Questions