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
<PackageReference Include="AzureWebJobs.SimpleInjector.Extensions" Version="1.0.0" />
paket add AzureWebJobs.SimpleInjector.Extensions --version 1.0.0
#r "nuget: AzureWebJobs.SimpleInjector.Extensions, 1.0.0"
// 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 | Versions 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. |
-
- Microsoft.Azure.WebJobs.Extensions (>= 2.2.0)
- NETStandard.Library (>= 1.6.1)
- Newtonsoft.Json (>= 9.0.1)
- SimpleInjector (>= 4.3.0)
- System.Collections (>= 4.3.0)
- System.Diagnostics.Debug (>= 4.3.0)
- System.Globalization (>= 4.3.0)
- System.IO (>= 4.3.0)
- System.Linq (>= 4.3.0)
- System.Linq.Expressions (>= 4.3.0)
- System.Net.Primitives (>= 4.3.0)
- System.ObjectModel (>= 4.3.0)
- System.Reflection (>= 4.3.0)
- System.Reflection.Extensions (>= 4.3.0)
- System.Resources.ResourceManager (>= 4.3.0)
- System.Runtime (>= 4.3.0)
- System.Runtime.Extensions (>= 4.3.0)
- System.Text.Encoding (>= 4.3.0)
- System.Text.Encoding.Extensions (>= 4.3.0)
- System.Text.RegularExpressions (>= 4.3.0)
- System.Threading (>= 4.3.0)
- System.Threading.Tasks (>= 4.3.0)
- System.Xml.ReaderWriter (>= 4.3.0)
- System.Xml.XDocument (>= 4.3.0)
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