如何使Azure Monitor Otel软件包在缺少Application Insights连接字符串时不会失败? 我将使用Azure Monitor OpentElemetry配置ASP.NET核心应用程序,以将日志发送到应用程序见解。 在使用新的Azure Monitor Otel Package Azure.Monitor.opentelemetry.aspnet ...

问题描述 投票:0回答:1
,该软件包已启用:

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


    

您可以通过测试连接字符串是否存在以下测试来避免该错误来避免该错误:

System.InvalidOperationException: A connection string was not found. Please set your connection string.

输出:
c# .net azure-application-insights azure-monitoring azure-monitor
1个回答
0
投票
工作没有任何例外:


    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.