Azure Runbook load .Net assembly for application insight

后端 未结 2 1288
难免孤独
难免孤独 2021-01-29 04:07

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

相关标签:
2条回答
  • 2021-01-29 04:57

    Try following path for the assembly "C:\Modules\Global\Azure\Compute\Microsoft.ApplicationInsights.dll"

    0 讨论(0)
  • 2021-01-29 05:00

    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

    0 讨论(0)
提交回复
热议问题