I have requirement where I want to write some metrics to the application insight for monitoring a service at a regular interval.
I though that I would write this PowerSh
Try following path for the assembly "C:\Modules\Global\Azure\Compute\Microsoft.ApplicationInsights.dll"
The issue is in loading the DLL file. The Runbook is not able to find the file in this line:
$AI = "$PSScriptRoot\Microsoft.ApplicationInsights.dll"
[Reflection.Assembly]::LoadFile("$AI")
When you run a Runbook via Azure Automation, you don't have access to the local path as you normally do on a local machine or on premise. In Azure Automation, modules are placed in "C:\Modules".
Instead, use below code snippet, after you have uploaded the dll file:
[System.Reflection.Assembly]::LoadFrom("C:\Modules\Azure\Microsoft.ApplicationInsights.dll")
Closest Related Reference: Referencing DLL