Reputation: 3064
Note: this question is specifically about a continuous WebJob using the WebJobs SDK, NOT Azure Functions.
Background: I have created a Console project in .NET Core 7, and added the WebJobs SDK. I created a TimerTrigger and was able to run it locally without any issues.
Now I'd like to add an HttpTrigger and test it locally. However I can't find any way to invoke the URL for the HttpTrigger function. The HTTP server doesn't even seem to be running for the webjobs (console) project. Please let me know how I can test the HttpTrigger function on localhost, when running an WebJobs SDK project.
Upvotes: 1
Views: 526
Reputation: 7392
I have used builder.AddHttp();
to invoke the HTTP Trigger.
I am unable to hit the endpoint from Azure Web Job.
My Program.cs file:
using Microsoft.Extensions.Hosting;
namespace WebJobsSDKSample
{
class Program
{
static async Task Main()
{
var builder = new HostBuilder();
builder.ConfigureWebJobs(b =>
{
b.AddHttp();
});
var host = builder.Build();
using (host)
{
await host.RunAsync();
}
}
}
}
MSDoc clearly says that invoking HTTP Trigger
cannot be done directly with Azure Web Jobs SDK.
The HTTP, Webhooks, and Event Grid bindings are supported only by Azure Functions, not by the WebJobs SDK.
Even the Github has the examples only for Queue,Blob and ServiceBus Triggers.
You can check this MSDoc, which clearly says
The WebJobs SDK does not have an HTTP trigger.
AFAIK, it is better to go with Azure Functions.
Refer SOThreads 1 and 2 for more details.
Upvotes: 0