Azure Automation Logging to Application Insight

﹥>﹥吖頭↗ 提交于 2019-12-24 09:40:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!