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

标签 azure logging azure-application-insights azure-monitoring

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

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

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

我尝试过 Azure Monitor 并创建了一个工作区,并在应用程序内使用了 HTTP Data Collector API,但在确定日志存储位置时并没有感到高兴。

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

我已经在谷歌上搜索了几个小时,但很多帖子都是 8 年前的帖子了,而且不相关,而且我在现代 Azure 中找不到一个简单的用例。

也许这很简单,我只是看不到

非常收到任何指针或链接!

谢谢 保罗

最佳答案

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

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

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

您只需创建一个 Application Insight 实例并使用遥测 key 即可完成此操作。

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} 
  });

关于azure - 从 ACI 上的容器内运行的控制台应用程序记录应用程序数据的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55936489/

相关文章:

f# - 如何将复杂的 Application Insights 引入 Farmer 部署?

azure - 当我在 App Insights 中打开实时指标时,为什么会收到 "Not available: your app is offline or using an older SDK'?

azure - 为什么 Azure AD Graph API 可能仍然比 Microsoft Graph API 更合适

azure - 如何构建代表 Azure 数据湖(第 2 代)的 Docker 镜像?

azure - 有没有办法获取任务 : "Azure Resource Group Deployment" 中使用的 SubscriptionID

performance - 在没有存储帐户支持的情况下远程收集Azure诊断日志

performance - Azure App Insights 延迟和开销

Azure 应用服务托管内部技术

sql-server - Amazon SQS 是处理分析日志数据到数据库的好工具吗?

design-patterns - 当需要日志记录时,您会考虑哪种设计模式?