我有一个公共(public) Web 应用程序,可以在其中设置 Azure 的可用性测试。我还有一个私有(private)网络应用程序,其可用性测试失败。
我想跟踪我的内部网络应用程序的可用性。在C#中,到目前为止我发现:
TelemetryConfiguration.Active.InstrumentationKey = "application insights key";
var telemetryClient = new TelemetryClient();
var avail = new Microsoft.ApplicationInsights.DataContracts.AvailabilityTelemetry();
telemetryClient.TrackAvailability(avail);
但是这段代码尚未完成。我不确定如何指定我的内部 URL 以及在哪里可以看到结果。
最佳答案
对于内部网络,首先,您应该确保“通过防火墙异常(exception)或代理重定向允许流量进入我们的服务。”,详细信息为 here .
然后只需一行简单的代码,只需在 AvailabilityTelemetry 中为您的内部 url 定义一些特定的属性或名称即可。
var client = new TelemetryClient();
TelemetryConfiguration.Active.InstrumentationKey = "xxxxx";
AvailabilityTelemetry a = new AvailabilityTelemetry();
a.Name = "this is your_web_site_name or other unique value";
//or some properties like below
//a.Properties.Add("p1", "my internal web");
client.TrackAvailability(a);
执行后,您可以检查可用性遥测是否在 Azure 门户 -> 您的应用程序洞察服务中:
关于c# - Azure设置内部url的可用性测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55282068/