@Amber Clark There are two ways you can develop HTTP functions when using .NET Isloted Worker.
Built-in HTTP Model
For this you need to return the HttpResponseData type as follows
[Function(nameof(Health))]
public async Task<HttpResponseData> Health([HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req)
{
var response = req.CreateResponse();
var status = await _healthCheckService.CheckHealthAsync();
await response.WriteAsJsonAsync(
Enum.GetName(typeof(HealthStatus), status.Status),
status.Status == HealthStatus.Healthy ? HttpStatusCode.OK : HttpStatusCode.ServiceUnavailable
);
return response;
}
ASP.NET Core integration (preview)
There are a few pre-requisites to get this model to work which are documented in the doc linked above. Here are the same for reference.
- Install the Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore NuGet package, version 1.0.0-preview2 or later (Note that you must check the
include prerelease
checkbox in Visual Studio)
Also, make sure Microsoft.Azure.Functions.Worker.Sdk is version 1.11.0 or later and Microsoft.Azure.Functions.Worker is version 1.16.0 or later.
- Replace
ConfigureFunctionsWorkerDefaults
withConfigureFunctionsWebApplication
inProgram.cs
- Use
HttpRequest
andIActionResult
types from ASP.NET - Add the
AzureWebJobsFeatureFlags
app setting with valueEnableHttpProxying