我是Powershell Runbook的新手,所以请原谅我,如果我失去了明显的东西。我正在尝试从我的脚本中记录Application Insights请求,但甚至无法加载DLL,尽管我已经看到其他代码非常类似。请注意,这是一个Powershell Runbook,而不是Powershell Workflow Runbook。Azure自动化Powershell Runbook默默无法LoadAssembly
这里是我的代码:
Write-Output "Starting"
$assemblyPath = "C:\Modules\Global\Azure\Compute\Microsoft.ApplicationInsights.dll"
dir $assemblyPath
Write-Output "1"
[System.Reflection.Assembly]::LoadFrom($assemblyPath)
Write-Output "2"
而这里的产量在测试窗格中运行它时,我得到:
Starting
Directory: C:\Modules\Global\Azure\Compute
Mode LastWriteTime Length Name
---- ------------- ------ ----
------ 1/11/2016 1:59 PM 152824 Microsoft.ApplicationInsights.dll
1
Starting
Directory: C:\Modules\Global\Azure\Compute
Mode LastWriteTime Length Name
---- ------------- ------ ----
------ 1/11/2016 1:59 PM 152824 Microsoft.ApplicationInsights.dll
1
Starting
Directory: C:\Modules\Global\Azure\Compute
Mode LastWriteTime Length Name
---- ------------- ------ ----
------ 1/11/2016 1:59 PM 152824 Microsoft.ApplicationInsights.dll
1
它似乎变得尽可能的LoadAssembly,然后掷骰子出来,在放弃之前运行脚本三次。任何想法我做错了什么?该DLL显然存在于该位置,并且我没有收到任何错误输出来帮助我进行调试。谢谢!
@BenH感谢您的回复,我真的看到了这篇文章,我应该提到我也尝试过这条路径,但程序集甚至不存在: dir:找不到路径'C :\ Modules \ Azure \ Microsoft.ApplicationInsights.dll'因为它不存在。 – UnionP
我能够通过切换到Powershell Runbook解决我的问题,并将所有.NET调用封装在InlineScript块中。不是最优雅的,但它的作品。仍然会喜欢听到有没有办法让这个工作不需要做, – UnionP
好,尝试做尝试和输出错误? – 4c74356b41