There is a newer version of this package available.
See the version list below for details.
dotnet add package Autofac.Extensions.DependencyInjection.AzureFunctions --version
NuGet\Install-Package Autofac.Extensions.DependencyInjection.AzureFunctions -Version
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="Autofac.Extensions.DependencyInjection.AzureFunctions" Version="" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Autofac.Extensions.DependencyInjection.AzureFunctions --version
#r "nuget: Autofac.Extensions.DependencyInjection.AzureFunctions,"
#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 Autofac.Extensions.DependencyInjection.AzureFunctions as a Cake Addin
#addin nuget:?package=Autofac.Extensions.DependencyInjection.AzureFunctions&version=

// Install Autofac.Extensions.DependencyInjection.AzureFunctions as a Cake Tool
#tool nuget:?package=Autofac.Extensions.DependencyInjection.AzureFunctions&version=


Autofac is an IoC container for Microsoft .NET. It manages the dependencies between classes so that applications stay easy to change as they grow in size and complexity. This is achieved by treating regular .NET classes as components.


Please file issues and pull requests for this package in this repository rather than in the Autofac core repo.

Get Started in Azure Functions

This quick start shows how to use the UseAutofacServiceProviderFactory integration to help automatically build the root service provider for you.

  • Reference the Autofac.Extensions.DependencyInjection.AzureFunctions package from NuGet.
  • Create your Startup class, following the documentation on how to Use dependency injection in .NET Azure Functions
  • In your Configure method, where you configure the IFunctionsHostBuilder, call UseAutofacServiceProviderFactory(ConfigureContainer) to hook Autofac into the startup pipeline.
  • In the ConfigureContainer method of your Startup class register things directly into an Autofac ContainerBuilder.
  • If you want to use functions declared in referenced projects, add <FunctionsInDependencies>true</FunctionsInDependencies> to the <PropertyGroup> of your main Azure Functions project.

The IServiceProvider will automatically be created for you, so there's nothing you have to do but register things.

using Microsoft.Azure.Functions.Extensions.DependencyInjection;

[assembly: FunctionsStartup(typeof(Startup))]

public class Startup : FunctionsStartup
    public override void Configure(IFunctionsHostBuilder builder)
            .UseAppSettings() // this is optional, this will bind IConfiguration in the container.

    private void ConfigureContainer(ContainerBuilder builder)
            .Register(activator =>
                // Example on how to bind settings from appsettings.json
                // to a class instance
                var mySettings = new MySettings();

                var config = activator.Resolve<IConfiguration>();

                return mySettings;

        // Register all functions that resides in a given namespace
        // The function class itself will be created using autofac
            .AsSelf() // Azure Functions core code resolves a function class by itself.
            .InstancePerTriggerRequest() // This will scope nested dependencies to each function execution



This is a basic function example, observe that classes and functions are not declared as static:

    public class Function1 : Disposable
        public Function1(IService1 service1, ILogger logger)
            // ...

        public async Task Run([QueueTrigger("myqueue-items", Connection = "AzureWebJobsStorage")]string myQueueItem)
            await Task.Delay(2000);
            _logger.LogInformation($"C# Queue trigger function processed: {myQueueItem}");

        // ...

Get Help

Need help with Autofac? We have a documentation site as well as API documentation. We're ready to answer your questions on Stack Overflow or check out the discussion forum.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Autofac.Extensions.DependencyInjection.AzureFunctions:

Package Downloads

Write More Code, Less Azure Functions. Functionless is a library to ease your Azure Function development by minimizing the abstraction of your long-running services, processes, workflows, etc.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated 178,859 10/14/2022 101,083 5/19/2022 235,342 8/11/2021 51,710 5/21/2021 18,062 4/27/2021 24,932 3/24/2021 46,039 10/6/2020 36,085 9/8/2020 142,264 4/6/2020 819 3/13/2020 853 3/13/2020 3,295 3/12/2020