问题
Is their any way to send custom tracking data from Azure Automation to application insight.
Ex:
workflow sample {
$instrumentationKey = "1234"
$TelemetryClient = /// how to get the telemetry client based on instrumentation key
$TelemetryClient.Track("New message")
$TelemetryClient.Flush()
}
Note: This is from Azure automation and not from standalone script
回答1:
This worked
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
}
}
来源:https://stackoverflow.com/questions/37039586/azure-automation-logging-to-application-insight