You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've created an Azure Function in C#, and attempting to utilize the dependency injection feature while also defining the Function parameters with a function.json file rather than the .net attributes so that I can use route parameters in the Function methods as described in Customize the HTTP Endpoint.
When I use the HttpTrigger and FunctionName attributes, the dependency injection works as expected. However, when I remove the attributes, and manually define the function.json file, the runtime throws an exception:
System.Private.CoreLib: Exception while executing function: MyClass.myFunction. Anonymously Hosted DynamicMethods Assembly: Object reference not set to an instance of an object.
To be sure, I've copied the automatically generated function.json file when using the attributes in order to ensure I hadn't miss-typed a value somewhere (removed the configurationSource field and ensured my written function.json file is in the output directory)
Versions and other information: .csproj file sample:
I haven't seen a sample of using dependency injection with route parameters, so I may have missed something in the setup. My Startup.cs file matches the example in the Dependency Injection docs.
Happy to provide any other information, or a reproducible example repo if needed.
The text was updated successfully, but these errors were encountered:
I've created an Azure Function in C#, and attempting to utilize the dependency injection feature while also defining the Function parameters with a
function.json
file rather than the .net attributes so that I can use route parameters in the Function methods as described in Customize the HTTP Endpoint.When I use the
HttpTrigger
andFunctionName
attributes, the dependency injection works as expected. However, when I remove the attributes, and manually define thefunction.json
file, the runtime throws an exception:To be sure, I've copied the automatically generated
function.json
file when using the attributes in order to ensure I hadn't miss-typed a value somewhere (removed theconfigurationSource
field and ensured my writtenfunction.json
file is in theoutput
directory)Versions and other information:
.csproj
file sample:Functions Core Tools:
I haven't seen a sample of using dependency injection with route parameters, so I may have missed something in the setup. My
Startup.cs
file matches the example in the Dependency Injection docs.Happy to provide any other information, or a reproducible example repo if needed.
The text was updated successfully, but these errors were encountered: