{"action":"created","issue":{"url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/issues/15","repository_url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection","labels_url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/issues/15/comments","events_url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/issues/15/events","html_url":"https://github.com/introtocomputerscience/azure-function-autofac-dependency-injection/issues/15","id":335306922,"node_id":"MDU6SXNzdWUzMzUzMDY5MjI=","number":15,"title":"Not working with Azure durable activity function","user":{"login":"goldytech","id":1241633,"node_id":"MDQ6VXNlcjEyNDE2MzM=","avatar_url":"https://avatars0.githubusercontent.com/u/1241633?v=4","gravatar_id":"","url":"https://api.github.com/users/goldytech","html_url":"https://github.com/goldytech","followers_url":"https://api.github.com/users/goldytech/followers","following_url":"https://api.github.com/users/goldytech/following{/other_user}","gists_url":"https://api.github.com/users/goldytech/gists{/gist_id}","starred_url":"https://api.github.com/users/goldytech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldytech/subscriptions","organizations_url":"https://api.github.com/users/goldytech/orgs","repos_url":"https://api.github.com/users/goldytech/repos","events_url":"https://api.github.com/users/goldytech/events{/privacy}","received_events_url":"https://api.github.com/users/goldytech/received_events","type":"User","site_admin":false},"labels":[{"id":733325460,"node_id":"MDU6TGFiZWw3MzMzMjU0NjA=","url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/labels/bug","name":"bug","color":"ee0701","default":true},{"id":990550121,"node_id":"MDU6TGFiZWw5OTA1NTAxMjE=","url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/labels/pending%20verification","name":"pending verification","color":"f7bf5d","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-06-25T08:27:22Z","updated_at":"2018-07-31T23:04:04Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\nI'm using this library in my Azure durable functions app.\r\nI've defined my DIConfig as follows, and when the function app starts I can see the ctor of this class is called with my activity function class name as functionName parameter value.\r\n\r\n\r\n```\r\n public  class DIConfig\r\n    {\r\n        /// <summary>\r\n        /// Initializes a new instance of the <see cref=\"DIConfig\"/> class.\r\n        /// </summary>\r\n        /// <param name=\"functionName\">\r\n        /// The function name.\r\n        /// </param>\r\n        public DIConfig(string functionName)\r\n        {\r\n            DependencyInjection.Initialize(\r\n                containerBuilder =>\r\n                    {\r\n                        containerBuilder.RegisterType<AuthenticationService>().As<IOAuthService>();\r\n                        containerBuilder.RegisterType<GenericAPIService>().As<IGenericAPIService>();\r\n                        containerBuilder.RegisterType<EmailTemplateNotificationService>().As<IEmailTemplateNotificationService>();\r\n                        containerBuilder.RegisterType<AicGenericSdk>().As<IAicGenericSdk>();\r\n                       containerBuilder.RegisterType<AgreementExpiryService>().As<IAgreementExpiryService>();\r\n                        containerBuilder.RegisterType<EmailReminderService>().As<IEmailReminderService>();\r\n                    },\r\n                functionName);\r\n        }\r\n    }\r\n```\r\n\r\nBelow is the code of my activity function , where I'm want to use DI\r\n\r\n```\r\n  [DependencyInjectionConfig(typeof(DIConfig))]\r\n    public static  class EmailReminderActivities\r\n    {\r\n     \r\n        [FunctionName(\"A_GetAgreementsForEmailReminder\")]\r\n        public static List<AgreementModel> GetAgreementsForEmailReminder(\r\n            [ActivityTrigger] string input,\r\n            TraceWriter log,\r\n            [Inject] IEmailReminderService emailReminderService)\r\n        {\r\n            \r\n          return (List<AgreementModel>)emailReminderService.GetAgreementsForReminderDate(input);\r\n        }\r\n    }\r\n```\r\n\r\nThis is the error I'm getting\r\n\r\n> A ScriptHost error has occurred\r\n[6/25/2018 8:20:44 AM] Exception while executing function: A_GetAgreementsForEmailReminder. Microsoft.Azure.WebJobs.Host: Exception binding parameter 'emailReminderService'. AzureFunctions.Autofac: DependencyInjection.Initialize must be called before dependencies can be resolved.\r\nIf I would have not use DI then this is how I would have initialize my EmailReminderService\r\n\r\n ` var emailReminderSvc = new EmailReminderService(new AicGenericSdk(new GenericAPIService(new AuthenticationService()),null ));`\r\n\r\nI hope I've registered dependencies in the right order.\r\nPlease help\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/issues/comments/409395848","html_url":"https://github.com/introtocomputerscience/azure-function-autofac-dependency-injection/issues/15#issuecomment-409395848","issue_url":"https://api.github.com/repos/introtocomputerscience/azure-function-autofac-dependency-injection/issues/15","id":409395848,"node_id":"MDEyOklzc3VlQ29tbWVudDQwOTM5NTg0OA==","user":{"login":"vandersmissenc","id":5750739,"node_id":"MDQ6VXNlcjU3NTA3Mzk=","avatar_url":"https://avatars2.githubusercontent.com/u/5750739?v=4","gravatar_id":"","url":"https://api.github.com/users/vandersmissenc","html_url":"https://github.com/vandersmissenc","followers_url":"https://api.github.com/users/vandersmissenc/followers","following_url":"https://api.github.com/users/vandersmissenc/following{/other_user}","gists_url":"https://api.github.com/users/vandersmissenc/gists{/gist_id}","starred_url":"https://api.github.com/users/vandersmissenc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vandersmissenc/subscriptions","organizations_url":"https://api.github.com/users/vandersmissenc/orgs","repos_url":"https://api.github.com/users/vandersmissenc/repos","events_url":"https://api.github.com/users/vandersmissenc/events{/privacy}","received_events_url":"https://api.github.com/users/vandersmissenc/received_events","type":"User","site_admin":false},"created_at":"2018-07-31T23:04:04Z","updated_at":"2018-07-31T23:04:04Z","author_association":"COLLABORATOR","body":"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?"}}
{"actor":{"display_login":"vandersmissenc"}}