从 ACI 容器内的控制台应用程序 运行 记录应用程序数据的最佳方式
Best way to log app data from a console app running inside a container on ACI
一个看似简单的问题,但没有找到最好的方法。
所以我需要从控制台应用程序记录应用程序事件,该应用程序将在容器内旋转并做一些工作然后死掉。
如何从内部记录自定义数据?
我尝试过 Azure Monitor 并创建了一个工作区,并在应用程序中使用了 HTTP 数据收集器 API,但我对确定日志的存储位置并不满意。
是否有一种简单的方法来登录到 Azure 存储帐户,然后使用 Azure Monitor 来管理事件?
我已经用谷歌搜索了几个小时,但很多帖子都是 8 年前的,而且不相关,我真的找不到现代 azure 中的简单用例。
也许太简单了,我就是看不出来
大大收到任何指针或链接!
谢谢
保罗
为什么不使用 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}
});
一个看似简单的问题,但没有找到最好的方法。
所以我需要从控制台应用程序记录应用程序事件,该应用程序将在容器内旋转并做一些工作然后死掉。
如何从内部记录自定义数据?
我尝试过 Azure Monitor 并创建了一个工作区,并在应用程序中使用了 HTTP 数据收集器 API,但我对确定日志的存储位置并不满意。
是否有一种简单的方法来登录到 Azure 存储帐户,然后使用 Azure Monitor 来管理事件?
我已经用谷歌搜索了几个小时,但很多帖子都是 8 年前的,而且不相关,我真的找不到现代 azure 中的简单用例。
也许太简单了,我就是看不出来
大大收到任何指针或链接!
谢谢 保罗
为什么不使用 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}
});