WebJobs.Extensions.HttpApi 2.0.0-preview3

This is a prerelease version of WebJobs.Extensions.HttpApi.
There is a newer version of this package available.
See the version list below for details.
dotnet add package WebJobs.Extensions.HttpApi --version 2.0.0-preview3
                    
NuGet\Install-Package WebJobs.Extensions.HttpApi -Version 2.0.0-preview3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WebJobs.Extensions.HttpApi" Version="2.0.0-preview3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WebJobs.Extensions.HttpApi" Version="2.0.0-preview3" />
                    
Directory.Packages.props
<PackageReference Include="WebJobs.Extensions.HttpApi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WebJobs.Extensions.HttpApi --version 2.0.0-preview3
                    
#r "nuget: WebJobs.Extensions.HttpApi, 2.0.0-preview3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=WebJobs.Extensions.HttpApi&version=2.0.0-preview3&prerelease
                    
Install WebJobs.Extensions.HttpApi as a Cake Addin
#tool nuget:?package=WebJobs.Extensions.HttpApi&version=2.0.0-preview3&prerelease
                    
Install WebJobs.Extensions.HttpApi as a Cake Tool

HTTP API Extensions for Azure Functions

Build Downloads NuGet License

Features

  • Model validation
  • ASP.NET Core like helpers
  • Support URL generation
  • Handle static files

Basic usage

Model validation

public class Function1 : HttpFunctionBase
{
    public Function1(IHttpContextAccessor httpContextAccessor)
        : base(httpContextAccessor)
    {
    }

    [FunctionName("Function1")]
    public IActionResult Run(
        [HttpTrigger(AuthorizationLevel.Function, "post")]
        SampleModel model,
        ILogger log)
    {
        if (!TryValidateModel(model))
        {
            return BadRequest(ModelState);
        }

        return Ok(model);
    }
}

public class SampleModel
{
    [Required]
    public string Name { get; set; }

    public string[] Array { get; set; }

    [Range(100, 10000)]
    public int Price { get; set; }
}

ASP.NET Core like helpers

public class Function2 : HttpFunctionBase
{
    public Function2(IHttpContextAccessor httpContextAccessor)
        : base(httpContextAccessor)
    {
    }

    [FunctionName("Function2")]
    public IActionResult Run(
        [HttpTrigger(AuthorizationLevel.Function, "get")]
        HttpRequest req,
        ILogger log)
    {
        Response.Headers.Add("Cache-Control", "no-cache");

        return Ok($"Now: {DateTime.Now}");
    }
}

Support URL generation

public class Function3 : HttpFunctionBase
{
    public Function3(IHttpContextAccessor httpContextAccessor)
        : base(httpContextAccessor)
    {
    }

    [FunctionName("Function3")]
    public IActionResult Run(
        [HttpTrigger(AuthorizationLevel.Function, "get", Route = "route/{id}")]
        HttpRequest req,
        string id,
        ILogger log)
    {
        return CreatedAtFunction("Function3", new { id = "kazuakix" }, null);
    }
}

Handle static files

public class Function1 : HttpFunctionBase
{
    public Function1(IHttpContextAccessor httpContextAccessor)
        : base(httpContextAccessor)
    {
    }

    [FunctionName("Function1")]
    public IActionResult Run(
        [HttpTrigger(AuthorizationLevel.Function, "get")] HttpRequest req,
        ILogger log)
    {
        return File("sample.html");
    }
}

License

This project is licensed under the MIT License

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on WebJobs.Extensions.HttpApi:

Repository Stars
shibayan/keyvault-acmebot
Automated ACME SSL/TLS certificates issuer for Azure Key Vault (App Service / Container Apps / App Gateway / Front Door / CDN / others)
shibayan/appservice-acmebot
Automated ACME SSL/TLS certificates issuer for Azure App Service (Web Apps / Functions / Containers)
shibayan/containerapps-acmebot
Automated ACME SSL/TLS certificates issuer for Azure Container Apps (Custom domain / Custom DNS Suffix)
Version Downloads Last updated
3.0.0 751 11/18/2024
3.0.0-preview1 98 8/4/2024
2.1.0 7,197 8/18/2023
2.0.3 10,187 12/9/2021
2.0.2 457 12/8/2021
2.0.1 601 12/8/2021
2.0.0 5,192 11/13/2021
2.0.0-preview5 280 11/11/2021
2.0.0-preview4 261 11/10/2021
2.0.0-preview3 331 10/27/2021
2.0.0-preview2 243 10/20/2021
2.0.0-preview1 270 9/14/2021
1.1.2 1,257 10/20/2021
1.1.1 1,470 7/12/2021
1.1.0 7,492 5/24/2020
1.0.2 953 4/4/2020
1.0.1 630 3/31/2020
1.0.0 586 3/16/2020