ApplicationInsightsRiderPlugin
ApplicationInsightsRiderPlugin copied to clipboard
Support (isolated) Azure Functions
I do not see the tab when debugging isolated azure functions. Will this be supported in the future?
I have the same issue, any chance you can get it working when debugging Azure functions?
The plugin is only listening to the Debug Output
from the attached program. I don't really know how the azure function work since they split it in 2 program.
Maybe you can try to attach to the other process if it's a dotnet one too and see the log are here ?
Also is this working in VS ?
No you are right, it also does not work in VS.
I tried with JetBrains Rider 2023.1.2. It partially works, but there is an issue. It doesn't show information logs, only warning or above.
In Azure, it shows the configured level: information logs and above:
documentation: https://learn.microsoft.com/en-us/azure/azure-monitor/app/worker-service
Does thos logs appear in Debug Output
tab (in rider, near between Console
and Paralell Stacks
?
Does thos logs appear in
Debug Output
tab (in rider, near betweenConsole
andParalell Stacks
?
only warning and above with this setting:
After testing other settings, I found this one to be working:
Then the problem is not in the extension, as I said before it's probably the same in VS. If they appear in VS and not in the extension then I would need to investigate.
I believe it works fine. However, Isolated Functions need some configuration. I have been able to do this as follow:
// references also: https://github.com/devops-circle/Azure-Functions-Logging-Tests/blob/master/Func.Isolated.Net7.With.AI/Program.cs
HostBuilder()
.ConfigureAppConfiguration( fun hostContext config ->
// Add appsettings.json configuration so we can set logging in configuration.
// Add in example a file called appsettings.json to the root and set the properties to:
// Build Action: Content
// Copy to Output Directory: Copy if newer
//
// Content:
// {
// "Logging": {
// "LogLevel": {
// "Default": "Error" // Change this to ie Trace for more logging
// }
// }
// }
//
// It's important to add json config sources before the call to ConfigureFunctionsWorkerDefaults as this
// adds environment variables into configuration enabling overrides by azure configuration settings.
config.AddJsonFile("appsettings.json", optional = true) |> ignore
)
.ConfigureOpenApi()
.ConfigureFunctionsWorkerDefaults(
fun (builder:IFunctionsWorkerApplicationBuilder) ->
let shouldUse (context: FunctionContext) =
let functionName = context.FunctionDefinition.Name.ToLowerInvariant()
(functionName.Contains("swagger")
|| functionName.Contains("openapi")
|| functionName.Contains("ping")
|| functionName.Contains("oauth2")) |> not
builder.UseWhen<UserIdMiddleware>(shouldUse) |> ignore
builder.UseWhen<TraceContextMiddleware>(shouldUse) |> ignore
)
.ConfigureServices(
fun context services ->
services.AddApplicationInsightsTelemetryWorkerService() |> ignore
services.ConfigureFunctionsApplicationInsights() |> ignore
// You will need extra configuration because above will only log per default Warning (default AI configuration) and above because of following line:
// https://github.com/microsoft/ApplicationInsights-dotnet/blob/main/NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs#L427
// This is documented here:
// https://github.com/microsoft/ApplicationInsights-dotnet/issues/2610#issuecomment-1316672650
// So remove the default logger rule (warning and above). This will result that the default will be Information.
services.Configure<LoggerFilterOptions>(fun (options:LoggerFilterOptions) ->
let toRemove = options.Rules.FirstOrDefault (fun rule -> rule.ProviderName = "Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider")
if toRemove <> null then
options.Rules.Remove(toRemove) |> ignore
) |> ignore
)
.ConfigureLogging(
fun hostingContext logging ->
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging")) |> ignore
)
.Build()
.Run()
The appsettings.json looks like this:
{
"Logging": {
"LogLevel": {
"Default": "Debug"
}
}
}
The plugin responds normally after the changes and seems to be working with Information level: