Try "C:\usr\src\PSModules\Microsoft.ApplicationInsights\Microsoft.ApplicationInsights.dll"
How to load assembly path in the new runtime experience in Automation Accounts' runbooks?
We have a runbook that we use to log to Application Insights. We use it for making logs both from Azure and Hybrid workers. In hybrid workers the logging works correctly, but in Azure it fails with
Cannot find type [Microsoft.ApplicationInsights.TelemetryClient]: verify that the assembly containing this type is loaded
Here's how we load the assembly to use the Microsoft.ApplicationInsights module in the code:
$AssemblyPathAzure = "C:\Modules\User\Microsoft.ApplicationInsights\Microsoft.ApplicationInsights.dll"
$AssemblyPathHybridWorker = "C:\Program Files\WindowsPowerShell\Modules\microsoft.applicationinsights.2.20.0\lib\net46\Microsoft.ApplicationInsights.dll"
try {Add-Type -Path $AssemblyPathAzure}
catch { $_.Exception.LoaderExceptions }
try {Add-Type -Path $AssemblyPathHybridWorker}
catch { $_.Exception.LoaderExceptions }
I've also tried the following path:
$AssemblyPathAzure = "C:\Modules\Global\Azure\Compute\Microsoft.ApplicationInsights.dll"
Both don't work in Azure.
I have a feeling that the import from "C:\Modules\User\Microsoft.ApplicationInsights\Microsoft.ApplicationInsights.dll" used to work before Accounts migrated to the new Runtime Experience
Could you help out with this issue?
1 answer
Sort by: Most helpful
-
Ambrose Wong 0 Reputation points Microsoft Employee
2025-02-16T22:46:49.0166667+00:00