他们是否可以通过任何方式将自定义跟踪数据从 Azure 自动化发送到应用程序洞察。
例如:
workflow sample {
$instrumentationKey = "1234"
$TelemetryClient = /// how to get the telemetry client based on instrumentation key
$TelemetryClient.Track("New message")
$TelemetryClient.Flush()
}
注意:这是来自 Azure 自动化,而不是来自独立脚本
最佳答案
这有效
workflow sample {
InlineScript {
$assemblyPath = "C:\Modules\Global\Azure\Compute\Microsoft.ApplicationInsights.dll"
[System.Reflection.Assembly]::LoadFrom($assemblyPath)
$TelClient = New-Object "Microsoft.ApplicationInsights.TelemetryClient"
$TelClient.InstrumentationKey = "1234"
$TelClient.TrackEvent("New message")
$TelClient.Flush
}
}
关于Azure 自动化记录到 Application Insight,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37039586/