AutofacOnFunctions: Named services support, fixes for breaking changes

A new version of Azure Functions was just released, called 1.0.19. While there are quite some changes in this release, like the fact that Function Apps must have exactly one single language and WebJobs had been updated to 3.0.0-beta8, there are some breaking changes. For complete information about the changes see the announcement.

Breaking Changes

Azure Functions Version 1.0.19 comes with some breaking changes. Extensions cannot be created like they had been before. Have a look at these links:

As AutofacOnFunction relies on the ExtensionConfigContext, there was some stuff to do. Actually, it was possible to fix all breaking changes in the AutofacOnFunctions nuget package itself. While these fixes had been applied, I just introduced a small feature that had been requested by community.

Named Services

Autofac allows for named services. AutofacOnFunctions had been enhanced to support named services in most initutive way. Actually there are only two steps to do.

First register your services by name.
[pastacode lang=”java” user=”holgerleichsenring” repos=”autofaconfunctions” path_id=”AutofacOnFunctions.Samples.NetStandard/Services/Modules/ServicesModule.cs” revision=”” highlight=”” lines=”” provider=”github”/]

Use the inject atttribute to specify the named instance:

[pastacode lang=”java” user=”holgerleichsenring” repos=”autofaconfunctions” path_id=”AutofacOnFunctions.Samples.NetStandard/Services/Functions/Function2.cs” revision=”” highlight=”” lines=”” provider=”github”/]

There are two samples available that work identically:
Net Standard
Net Framework


  1. benjamin said:

    This is really great !

    can you use parameters in the name ?

    function :
    [HttpTrigger(AuthorizationLevel.Anonymous, “get”, “post”, Route = “demo/{myParam}”)]HttpRequest req,
    string myParam,
    [Inject(“named{myParam}”)] IEventValidator validator,

    module :


    November 20, 2018
    • Holger Leichsenring said:

      Hi Benjamin,

      no, this is not supported by now, but it is a quite interesting idea. 🙂
      As the HttpTrigger supports that, just one question to the “[Inject(“named{myParam}”)]”. You registered the type via names namedA and B. Does it mean, myParam is either A or B? There is one problem in resolving the type. I need to check if it is possible to read out all parameters to use myParam for resolving named{myParam}. Will have a look!


      November 21, 2018
      • benjamin said:

        hi Holger

        yes, myParam is either “A” or “B”

        there is a problem in my previous comment , we should read :
        module :
        builder.RegisterType ().Named(“namedA”);
        builder.RegisterType ().Named(“namedB”);

        this should really be a great feature !

        November 21, 2018
        • benjamin said:

          generics in html :/
          builder.RegisterType EventValidatorA ().Named(“namedA”);
          builder.RegisterType EventValidator ().Named(“namedB”);

          November 21, 2018

Comments are closed.