Git Product home page Git Product logo

Comments (19)

rawrspace avatar rawrspace commented on September 11, 2024

Do you have a repository you can share that reproduces the issue?

Also validate that AuthenticationService has a parameter less constructor.

That GenericApiService has a constructor that takes an IOAuthService.

That AicGenericSdk has an constructor that takes an IGenericAPIService.

And an EmailReminderService constructor that takes an IAicGenericSdk.

If you don't want to have those constructors take interfaces as the parameters you will need to use builder.Register instead of RegisterType.

from azure-function-autofac-dependency-injection.

goldytech avatar goldytech commented on September 11, 2024

All the ctors have proper parameters the way you described it.

Here is the code link

https://drive.google.com/file/d/1ZVO98BNwpJcX85iI0AP17MOD10_DVRVj/view?usp=sharing

from azure-function-autofac-dependency-injection.

fingersmagoo avatar fingersmagoo commented on September 11, 2024

I am experiencing the same issue. (ServiceBus Queue Trigger)

from azure-function-autofac-dependency-injection.

rawrspace avatar rawrspace commented on September 11, 2024

@goldytech It looks like the files have been removed from Google drive. Can you share them via GitHub?
@fingersmagoo Do you have a sample project I can verify this issue with?
Additionally what version of the package are you using and is it a v1(.net framework) or v2(.net core) function? I am currently using durable functions with both http triggers and service bus triggers without this error.

from azure-function-autofac-dependency-injection.

aboutdomtime avatar aboutdomtime commented on September 11, 2024

I didn't get to look at the source in detail, but I would classify the problem the OP is having as a limitation rather than a bug. The issue he's having would arise in the case of Durable functions more so because there is an increased likelihood of having the pattern class A { function x,y,z } (an orchestrator with multiple nested activity functions). The line if (containers.ContainsKey(functionName)) in DependencyInjection.cs would most likely fail as containers would only contain the name of the Declaring Type as the Key which it would try to match against the functionName which would be different. Also if the class name is different from the functionName it seems like it might fail as well.

from azure-function-autofac-dependency-injection.

tstone84 avatar tstone84 commented on September 11, 2024

Is there a workaround for this or will there be a change to allow this to work with Durable Functions? I was planning on using this for my Durable Functions (which I just started building), but obviously will need to find another solution if this one doesn't work with them. Thanks for providing this library!

from azure-function-autofac-dependency-injection.

rawrspace avatar rawrspace commented on September 11, 2024

I have not been able to replicate this issue. I am currently using this package with durable functions and it is working as expected. Can you provide a sample project so that I can validate this issue?

from azure-function-autofac-dependency-injection.

tstone84 avatar tstone84 commented on September 11, 2024

@vandersmissenc I haven't experienced an issue yet, but was assuming based on the OP that it didn't support Durable Functions. It's great to hear that that's not the case! I will give it a go. I was just trying to hedge before getting too far down a given path. Thanks again for a great solution!

from azure-function-autofac-dependency-injection.

tstone84 avatar tstone84 commented on September 11, 2024

@vandersmissenc Just gave it a shot with my Durable Functions and I'm getting this:
Method not found: 'Void AzureFunctions.Autofac.Configuration.DependencyInjection.Initialize(System.Action`1<Autofac.ContainerBuilder>, System.String

It's very possible i'm doing something incorrectly, but I followed the information from the ReadMe.

Any help would be greatly appreciated!

from azure-function-autofac-dependency-injection.

rawrspace avatar rawrspace commented on September 11, 2024

Is this an azure functions v1(.net framework) or v2(.net core)? Do you have either the steps to reproduce this or a reproduction repo I can check out? @tstone84

from azure-function-autofac-dependency-injection.

rawrspace avatar rawrspace commented on September 11, 2024

I have been able to replicate this issue locally. The problem appears to be that when the dependency injection config is created it registers for the class and it uses the class name as the key but when the individual method tries to resolve objects it uses the function name. If you only have one function in your class as the name is the same as the class name you would not see this behavior.

I have made an update in the code and I am currently testing to verify it is resolved. I will keep you updated. Thanks for reporting the issue.

from azure-function-autofac-dependency-injection.

rawrspace avatar rawrspace commented on September 11, 2024

I pushed the fix to nuget as a beta package. I will validate tomorrow that is resolves the issues when installed via nuget and if so I will push the full version and resolve this issue.

from azure-function-autofac-dependency-injection.

tstone84 avatar tstone84 commented on September 11, 2024

@vandersmissenc Sorry, I wasn't able to respond last night. Thanks for looking into this and providing a fix! I'll pull down the pre-release version and give it a go.

from azure-function-autofac-dependency-injection.

rawrspace avatar rawrspace commented on September 11, 2024

I was testing it this morning and if you create a fresh project and just install Microsoft.Azure.WebJobs.Extensions.DurableTask and AzureFunctions.Autofac then it works fine. There appears to be a conflict with another package because in my more complex solution I am seeing the method not found exception still. After you test it out let me know what you see and if possible the packages you are referencing in your project @tstone84

from azure-function-autofac-dependency-injection.

rawrspace avatar rawrspace commented on September 11, 2024

I have narrowed down the issue to Autofac. When I install my external package it installs Autofac 4.6.2 which then produces the method not found exception. I have tried upgrading to 4.8.1 but the same error occurs. I have the package right now relying on Autofac 4.2.1 since that is what Azure Functions Host uses but it seems like I have to set a hard restriction to that version.

from azure-function-autofac-dependency-injection.

tstone84 avatar tstone84 commented on September 11, 2024

@vandersmissenc Yep, I'm still seeing the issue with the beta package. Originally, I was on 4.8.1 of Autofac and downgraded to 4.2.1 to try to resolve it after seeing some threads online about that issue, but didn't have any success. Again, I appreciate your quick response and you looking into this. Thx!
BTW, I'm currently using v1 of Azure functions because I'm stuck with some .Net Framework internal libs that I can't update to net standard for now.

from azure-function-autofac-dependency-injection.

rawrspace avatar rawrspace commented on September 11, 2024

Can you install 3.02-beta04 and see if you still have issues? I was able to remove my dependency on Autofac in my external package and I am no longer having issues with this version of the package. If you are still having issues can you provide a repo project I can check out? Thanks @tstone84

from azure-function-autofac-dependency-injection.

tvperez76 avatar tvperez76 commented on September 11, 2024

It appears that this issue has sprung up again. I am using Autofac 4.9.4, Autofac.Extensions.DependencyInjection 4.4.0 and AzureFunctions.Autofac 3.0.7. Was there a change that caused such a regression?

from azure-function-autofac-dependency-injection.

rawrspace avatar rawrspace commented on September 11, 2024

You must use Autofac 4.2.1 due to restrictions in Azure Functions. Please try with that version and see if you still have problems.

from azure-function-autofac-dependency-injection.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.