Microsoft.ApplicationInsights.AspNetCore
在这里,如果没有应用程序见解连接字符串,它将默默地继续。,但是,使用新软件包,如果连接字符串不可用,我会发现一个错误:
builder.Services.AddApplicationInsightsTelemetry();
eRror:
builder.Services.AddOpenTelemetry().UseAzureMonitor();
我如何使用新软件包,以免它在缺少的连接字符串上失败,而是默默地继续?
https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-configuration?tabs =aspnetcore
您可以通过测试连接字符串是否存在以下测试来避免该错误来避免该错误:输出: