AzureWebJobs.SimpleInjector.Extensions 1.0.0

dotnet add package AzureWebJobs.SimpleInjector.Extensions --version 1.0.0
NuGet\Install-Package AzureWebJobs.SimpleInjector.Extensions -Version 1.0.0
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="AzureWebJobs.SimpleInjector.Extensions" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AzureWebJobs.SimpleInjector.Extensions --version 1.0.0
#r "nuget: AzureWebJobs.SimpleInjector.Extensions, 1.0.0"
#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.
// Install AzureWebJobs.SimpleInjector.Extensions as a Cake Addin
#addin nuget:?package=AzureWebJobs.SimpleInjector.Extensions&version=1.0.0

// Install AzureWebJobs.SimpleInjector.Extensions as a Cake Tool
#tool nuget:?package=AzureWebJobs.SimpleInjector.Extensions&version=1.0.0

Microsoft.Azure.WebJobs.Extensions.SimpleInjector

SimpleInjector extensions for cleaner DI setup in Azure WebJobs

Set up

static void Main()
    {
        var config = new JobHostConfiguration();

      
            config.UseDevelopmentSettings();
        

        config.UseTimers();
        config.UseSimpleInjector(DITestRegistrations.Register, "I'm the additional param", new AsyncScopedLifestyle());

        var host = new JobHost(config);
        // The following code ensures that the WebJob will be running continuously
        host.RunAndBlock();
    }  
      
      
      

The following code snippet shows the extension method on the JobHostConfiguration which takes in an Action<object> where your DI registrations should live. Passing it a new AsyncScopedLifestyle does not set any of the default lifestyles of the container. All this does is create an explicit scoped lifestyle when your functions are called and disposes your lifestyle. If your DI classes are all singletons then just pass it a null and the extensions will not bother creating explicit scopes.

Inject services into function

 // This function will get triggered/executed when a new message is written 
    // on an Azure Queue called queue.
    public static void ProcessQueueMessage([TimerTrigger("0 59 23 * * *", RunOnStartup = true)] //At 11:59PM
    TimerInfo info, ICancelWroBoxProcess process)
    {

            process.Begin();
    }

In the above scenario, the ICancelWroBoxProcess will be injected. If you fail to register a service and attempt to inject it, you will receive an exception. Please create a unit test for your DI registrations.

Product Compatible and additional computed target framework versions.
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
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

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 24,733 7/30/2018

Initial release