c# - Azure设置内部url的可用性测试

标签 c# .net azure azure-web-app-service azure-application-insights

我有一个公共(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 门户 -> 您的应用程序洞察服务中:

enter image description here

关于c# - Azure设置内部url的可用性测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55282068/

相关文章:

c# - 从 C# 调用非托管代码

c# - 有人可以用英语向我解释这段 MSDN 代码吗?

c# - 具有监视器进入/退出、等待/脉冲、锁定的多线程

c# - 在 C# 中对队列进行排序

c# - OpenCV: src.depth() == dst.depth() && src.size == dst.size 异常

c# - Microsoft.Azure.ServiceBus 如何获取消息状态

c# - .NET 标准说明

c# - 安全地验证客户端到服务器

asp.net - 本地 Azure 开发环境出现 403 错误的原因是什么?

azure - 无法在 AppService 中使用 Active Directory 集成身份验证连接到 Azure SQL Server