-
Notifications
You must be signed in to change notification settings - Fork 192
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
Logging not working in Azure Function Isolated Model #2389
Comments
Could you please try using the setup code mentioned in our documentation here? When deploying your app, simply add the By following this model, your dotnet isolated function will send logs directly to Application Insights, bypassing the host, similar to how AI integration works for any .NET application. Let us know how that goes. |
Is there an issue with using the Application Insights connection string? Since instrumentation key support will end in less than a year. |
I have followed the mentioned documentation Deployed function app has right set of APPINSIGHTS_INSTRUMENTATIONKEY & APPLICATIONINSIGHTS_CONNECTION_STRING as well. How do I know it is right? Because the setting is imported into local.settings.json & when the function is running locally, I can see the logs in AI. But logs are not reaching AI from deployed function app. I know that the function app is executing because i can see entries in exception table in AI. But I don't see any entries in traces. I am obtaining logger instance from FunctionContext.GetLogger( |
How do you know "what" is right? Can you be more specific? The Can you try creating a new AI resource, copy it's connection string and update your deployed app's |
Use below code in Program.cs, it will start working, Also do proper DI in function class for ILogger, var host = new HostBuilder()
}) |
FYI, the workaround supplied by @sopya88 above doesn't fix anything, at least in the solution I'm running. |
@chayankar I think you would benefit from following the sample I shared. It works reliably across both Windows and Linux app service plans. Please, let me know if that solves your issue. |
What version of .NET does your existing project use?
.NET 6
What version of .NET are you attempting to target?
.NET 6
Description
Upgrading azure function in-process model into isolated model. Followed the steps mentioned [here](https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=windows#logging)
When running the function locally, I can see the logs reaching Application Insight, but after deploying it into azure I don't see logs reaching Application Insight, neither in Log Stream.
When working locally, I imported application settings from deployed function app in azure. I am sure that APPINSIGHTS_INSTRUMENTATIONKEY & APPLICATIONINSIGHTS_CONNECTION_STRING are correct.
I tried using Serilog for writing logs into Application Insight using Serilog.Sinks.ApplicationInsights (4.0.0) but the result is same as above.
Used both approaches for obtaining logger instance: Using dependency insjection & via FuctionContext.GetLogger(categoryName) method.
My question is: If function is generating logs when ran locally, then why is it not working as expected in azure?
Is the worker process not communicating with host? Is there any other unknown configuration which is overriding my code?
Do we have to define log level for the categaoryName parameter passed into FuctionContext.GetLogger(categoryName) host.json?
Below is the snippet from startup class.
host.json
Links referred:
#1123
#944
#702
#760
#1123
Project configuration and dependencies
Startup project .csproj file content
Link to a repository that reproduces the issue
No response
The text was updated successfully, but these errors were encountered: