Officium.Tools 2.1.0

Extends Azure functions to support routing to handlers, auth, validation and more

Install-Package Officium.Tools -Version 2.1.0
dotnet add package Officium.Tools --version 2.1.0
<PackageReference Include="Officium.Tools" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Officium.Tools --version 2.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Officium

Overview

Officium is a suite of tools for rapid development of Azure Http triggered functions using existing IoC frameworks

Quick start

Prerequisites

Setup your Azure Function to Use Dependency injection
https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-dependency-injection

Add a reference to Offcium.Tools

Install-Package Officium.Tools

Steps

Add 2 line to your Azure startup file (in the configure method)

 public class Startup : FunctionsStartup
    {
        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.Services.AddPlugins(); // find and register all classes implementing 'IFunctionPlugin'
            builder.Services.AddOficuimServices(); // add the services we'll need
        }
    }

Add a constructor to your azure function , with a private field

private readonly IExecutor executor;

   public Function1(IExecutor executor)
   {
      this.executor = executor;
   } 

In the Run method, Add a line to start routing requests to your handlers

public IActionResult Run(
        [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "v1/{n1?}")] HttpRequest req,
        ILogger log)
        {           
            return executor.ExecuteRequest(req, log);
        }

Finally add your handler

public class HelloWorldPlugin : IFunctionPlugin
{
    public PluginStepOrder StepOrder => PluginStepOrder.OnGet; // run this on every get request

    public IActionResult ExecuteRequest(HttpRequest req, ILogger logger, IPluginContext context)
    {
        string name = req.Query["name"];
        return name != null
            ? (ActionResult)new OkObjectResult($"Hello, {name}")
            : new BadRequestObjectResult("Please pass a name on the query string or in the request body");
    }
}

Officium

Overview

Officium is a suite of tools for rapid development of Azure Http triggered functions using existing IoC frameworks

Quick start

Prerequisites

Setup your Azure Function to Use Dependency injection
https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-dependency-injection

Add a reference to Offcium.Tools

Install-Package Officium.Tools

Steps

Add 2 line to your Azure startup file (in the configure method)

 public class Startup : FunctionsStartup
    {
        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.Services.AddPlugins(); // find and register all classes implementing 'IFunctionPlugin'
            builder.Services.AddOficuimServices(); // add the services we'll need
        }
    }

Add a constructor to your azure function , with a private field

private readonly IExecutor executor;

   public Function1(IExecutor executor)
   {
      this.executor = executor;
   } 

In the Run method, Add a line to start routing requests to your handlers

public IActionResult Run(
        [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "v1/{n1?}")] HttpRequest req,
        ILogger log)
        {           
            return executor.ExecuteRequest(req, log);
        }

Finally add your handler

public class HelloWorldPlugin : IFunctionPlugin
{
    public PluginStepOrder StepOrder => PluginStepOrder.OnGet; // run this on every get request

    public IActionResult ExecuteRequest(HttpRequest req, ILogger logger, IPluginContext context)
    {
        string name = req.Query["name"];
        return name != null
            ? (ActionResult)new OkObjectResult($"Hello, {name}")
            : new BadRequestObjectResult("Please pass a name on the query string or in the request body");
    }
}

Release Notes

Added HaltExecution , and OnHanderExecuted

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
2.1.0 46 9/11/2019
2.0.0 46 9/9/2019
1.1.4-alpha 40 9/1/2019
1.1.3-alpha 39 8/31/2019
1.0.2-alpha 39 8/31/2019
1.0.1-alpha 38 8/30/2019
1.0.0 57 8/26/2019
0.0.2-alpha 48 8/24/2019
0.0.1-alpha 50 8/16/2019