-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TelemetryConfiguration does not resolve from DI #35181
Comments
@cecilphillip Thank you for your feedback . We will have this reviewed with engineering and update the article as needed. |
@cecilphillip Make sure you have the latest nuget package of Microsoft.NET.Sdk.Functions. |
@DixitArora-MSFT @shashishailaj Even, I am getting the same issue for the function app while trying to implement custom telemetry logging. I am using the v1.0.29 of the Microsoft.NET.Sdk.Functions nuget package |
@cecilphillip - As per the Microsoft documentation - link, Azure Function's inbuilt App Insights support works with the v2.9.1 of App Insights. Once i downgraded the App Insight version to 2.9.1, it started working. This is not working with v2.10.0. I am not sure whether this is a bug or it is an expected behaviour. |
I created a new Function app and changed the NuGet package version fro AppInsights, but still getting the same errors. This still doesn’t work for me. Here are all my details Code public class Function1
{
private readonly TelemetryConfiguration tconf;
public Function1(TelemetryConfiguration tconf)
{
this.tconf = tconf;
}
[FunctionName("Function1")]
public async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
return new OkResult();
}
} Project file
Functions runtime
@lolekjohn do you have the same version of core tools and the runtime? |
@cecilphillip Why are you using
in the constructor? |
The code snipped was just to validate issue I was having. I’m pulling in Also, I’ve sorted this out with 2.9.1. I needed to add |
@cecilphillip and I were chatting on IM -- there's 2 things I think we should do in the docs:
|
It would be better if the Documentation in https://docs.microsoft.com/en-us/azure/azure-functions/functions-monitoring#log-custom-telemetry-in-c-functions is updated accordingly so that the correct app insights can be used |
@lolekjohn -- my comment says that we need to update the docs... is there something different you'd like the docs to say than what I listed? What do you mean by the "correct app insights"? |
My bad. I don't have anything else to be added. I meant correct App Insights nuget package can be used. |
Oh, sure -- note that the package I mentioned above does reference the real App Insights as a dependency, it just may be slightly behind the newest public version. Some more details for anyone else that may stumble across this: The scenario where you get into these cases where types aren't found, using the current state as an example:
We're currently waiting for step 5 to complete, so local references to 2.10.0 won't find these types in DI. I've also logged Azure/azure-functions-host#4682 to see if we can bake some of this directly into the host -- if we show you a warning or error if you get ahead of the host references,. |
@cecilphillip Brettsam has already open another issue for tracking. So for now I will proceed with the closure of this. |
Retrieving an instance of TelemetryConfiguration via constructor injection as stated in this document under Log custom telemetry in C# functions throws an error.
Other services that I have registered resolve correctly via the DI support in Functions
Using
Azure Functions Core Tools (2.7.1373 Commit hash: cd9bfca26f9c7fe06ce245f5bf69bc6486a685dd)
Function Runtime Version: 2.0.12507.0
Visual Studio 2019 16.2 preview 3
@fabiocav @brettsam
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: