从ACI上的容器内运行的控制台应用程序记录应用程序数据的最佳方法

问题描述 投票:0回答:1

一个看似简单的问题,但没有找到最好的方法。

因此,我需要从控制台应用程序中记录应用程序事件,该应用程序将在容器内旋转并执行一些工作然后死亡。

如何从内部记录自定义数据?

我已经尝试过Azure Monitor并创建了一个工作区,并在应用程序中使用了HTTP Data Collector API,但是在计算存储日志的位置时没有任何乐趣。

是否有一种简单的方法可以登录Azure存储帐户,然后使用Azure Monitor管理事件?

我一直在谷歌搜索几个小时,但很多帖子都是8岁,并没有相关性,我真的找不到现代天蓝色的简单用例。

也许它是如此简单,我只是看不到它

任何指针或链接都很受欢迎!

谢谢保罗

azure logging azure-application-insights azure-monitoring
1个回答
2
投票

为什么不使用Application Insight自定义事件跟踪事件?

https://docs.microsoft.com/en-us/azure/azure-monitor/app/api-custom-events-metrics

您可以使用任何元数据跟踪事件,并在Azure Application Insights Blade中检查它们,或通过Application Insights SDK或Api访问它们。

您只需创建一个Application Insight实例并使用遥测密钥来执行此操作。

SDK:https://github.com/Microsoft/ApplicationInsights-dotnet

API:https://dev.applicationinsights.io/reference

用于编写事件的代码示例:

  TelemetryClient client = new TelemetryClient();
  client .InstrumentationKey = "INSERT YOUR KEY";
  client.TrackEvent("SomethingInterestingHappened");

您还可以发送多个字符串值:

tc.TrackEvent("PurchaseOrderSubmitted", 
  new Dictionary<string, string>() 
  { 
    {"CouponCode", "JULY2015" } 
  }, new Dictionary<string, double>() 
  { 
    {"OrderTotal", 68.99 }, 
    {"ItemsOrdered", 5} 
  });
© www.soinside.com 2019 - 2024. All rights reserved.